time-link / timelink-py

Timelink Python Package
MIT License
3 stars 0 forks source link

Dataframe with value counts of an attribute type #15

Closed joaquimrcarvalho closed 9 months ago

joaquimrcarvalho commented 10 months ago

Something exists in timelink.notebooks.pandas


def attribute_values(
    attr_type,
    db: TimelinkDatabase = None,
    session: sessionmaker = None,
    dates_between=None,
    sql_echo=False,
):
    """Return the vocabulary of an attribute

    The returned dataframe has a row for each unique value
    a 'count' with the number of different entities, and
    the the first and last date for that row

    Args:
        attr_type = attribute type to search for
        db = database connection to use, either db or session must be specified
        session = session to use, either db or session must be specified
        dates_between = tuple with two dates in format yyyy-mm-dd
        sql_echo = if true will print the sql statement

    To filter by dates: dates_in = (from_date,to_date)
    with dates in format yyyy-mm-dd
    will return attributes with
    from_date < date < to_date

    """