Skip to content

temporian.to_pandas #

to_pandas(
    evset: EventSet,
    tp_string_to_pd_string: bool = True,
    timestamp_to_datetime: bool = True,
    timestamps: bool = True,
) -> pandas.DataFrame

Converts an EventSet to a pandas DataFrame.

Usage example
>>> from datetime import datetime

>>> evset = tp.event_set(
...     timestamps=[datetime(2015, 1, 1), datetime(2015, 1, 2)],
...     features={
...         "feature_1": [0.5, 0.6],
...         "my_index": ["red", "red"],
...     },
...     indexes=["my_index"],
... )

# Indices are not set as dataframe's indices. Timestamps are exported as
# datetime64[s] if they were created as datetimes, otherwhise they are
# floats
>>> df = tp.to_pandas(evset)
>>> df
my_index   feature_1     timestamp
0       red        0.5  2015-01-01
1       red        0.6  2015-01-02

# Set index/date manually in pandas
>>> df.set_index("my_index")
            feature_1  timestamp
my_index
red         0.5     2015-01-01
red         0.6     2015-01-02

Parameters:

Name Type Description Default
evset EventSet

Input event set.

required
tp_string_to_pd_string bool

If true, cast Temporian strings (equivalent to np.string_ or np.bytes) to Pandas strings (equivalent to np.str_).

True
timestamp_to_datetime bool

If true, cast Temporian timestamps to datetime64 when is_unix_timestamp is set to True.

True
timestamps bool

If true, the timestamps are included as a column.

True

Returns:

Type Description
DataFrame

DataFrame created from EventSet.