time-link / timelink-py

Timelink Python Package
MIT License
3 stars 0 forks source link

Generate a Pandas data frame with entities with a given attribute #13

Closed joaquimrcarvalho closed 10 months ago

joaquimrcarvalho commented 10 months ago

Something exists in timeline.notebooks.pandas.init

Better name: entities_with_attribute

def attribute_to_df(
    the_type,
    the_value=None,
    column_name=None,
    person_info=True,
    dates_in=None,
    name_like=None,
    filter_by=None,
    more_cols=None,
    db: TimelinkDatabase = None,
    sql_echo=False,
):
    """Generate a pandas dataframe with people with a given attribute

    Args:
        the_type    : type of attribute, can have SQL wildcards, string
        column_name : a name for column receiving the attribute type, string
        the_value   : if present, limit to this value, can be SQL wildcard,
                       string or list of strings
        person_info : if True add name and sex of person, otherwise just id
        dates_in    : (after,before) if present only between those dates (exclusive)
        name_like   : name must match pattern (will set person_info = True),
        filter_by   : list of ids, limit to these
        more_cols   : add more attributes if available
        db          : A TimelinkMHK object
        sql_echo    : if True echo the sql generated

    Note that if person_info = True the columns 'name' and 'sex' will be added.

    Ideas:
        Add : the_value_in: (list of values)
              the_value_between(min, max, exclude_min=True|False, exclude_max=True|False)