Skip to content

Commit

Permalink
feat: optional static vars
Browse files Browse the repository at this point in the history
  • Loading branch information
martibosch committed Apr 25, 2024
1 parent 3a32604 commit 1feb60c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tstore/tslong/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ def to_tstore(
id_var,
time_var,
ts_variables,
static_variables,
static_variables=None,
# TSTORE options
partitioning=None,
tstore_structure="id-var",
overwrite=True,
):
"""TSLONG.to_tstore()."""
# If index time, remove
df = df.reset_index(names=time_var)
if time_var not in df.columns:
df = df.reset_index(names=time_var)

Check warning on line 73 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L72-L73

Added lines #L72 - L73 were not covered by tests

# Set identifier as pyarrow large_string !
# - Very important to join attrs at read time !
Expand All @@ -93,8 +94,11 @@ def to_tstore(
partitioning = check_partitioning(partitioning, ts_variables=list(ts_variables))

# Identify static dataframe (attributes)
attr_cols = [id_var]
if static_variables is not None:
attr_cols += static_variables

Check warning on line 99 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L97-L99

Added lines #L97 - L99 were not covered by tests
# - TODO: add flag to check if are actual duplicates !
df_attrs = df[[id_var, *static_variables]]
df_attrs = df[attr_cols]

Check warning on line 101 in tstore/tslong/pandas.py

View check run for this annotation

Codecov / codecov/patch

tstore/tslong/pandas.py#L101

Added line #L101 was not covered by tests
df_attrs = df_attrs.drop_duplicates(subset=id_var)
df_attrs = df_attrs.reset_index(drop=True)

Expand Down

0 comments on commit 1feb60c

Please sign in to comment.