Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Clean up code #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[FIX] Clean up code #310

wants to merge 1 commit into from

Conversation

elephaint
Copy link
Contributor

@elephaint elephaint commented Nov 29, 2024

  • Cleans up old aggregation function
  • Fixes minor function that always returned pandas df. It now takes a string argument backend that will return a df of the chosen backend
  • Improve type annotation
  • Removes asserts in favor of ValueErrors

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@elephaint elephaint added the fix label Nov 29, 2024
@elephaint elephaint marked this pull request as ready for review November 29, 2024 09:47
def _to_upper_hierarchy(bottom_split, bottom_values, upper_key):
# %% ../nbs/src/utils.ipynb 10
def _to_upper_hierarchy(
bottom_split: List[str], bottom_values: str, upper_key: str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that the min python is 3.9 you could use the collections directly, e.g. list[str] instead of typing.List[str

Comment on lines +642 to +646
df_nw = nw.from_dict(
{id_col: unique_ids, time_col: ds, model_name: forecasts_mean},
native_namespace=namespace,
)
df_nw = df_nw.with_columns(**dict(zip(col_names, forecasts_quantiles.T)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be more efficient to create the df in one go

Suggested change
df_nw = nw.from_dict(
{id_col: unique_ids, time_col: ds, model_name: forecasts_mean},
native_namespace=namespace,
)
df_nw = df_nw.with_columns(**dict(zip(col_names, forecasts_quantiles.T)))
df_nw = nw.from_dict(
{
**{id_col: unique_ids, time_col: ds, model_name: forecasts_mean},
**dict(zip(col_names, forecasts_quantiles.T)),
},
native_namespace=namespace,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants