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

Add to_dataframe to ItemSet; support datetime.datetime #44

Merged
merged 4 commits into from
Aug 16, 2023

Conversation

cranti
Copy link
Contributor

@cranti cranti commented Aug 11, 2023

Two minor improvements:

  • Adding a convenience method to the ItemSet class, to create a pandas dataframe representing the items in the set
  • Adding support for datetime.datetime as an input for get_stream_data and get_stream_availability. These functions currently accept datetime.date, which only has precision to the day.

@cranti cranti requested a review from a team August 11, 2023 15:16

def to_dataframe(self) -> pd.DataFrame:
"""Convert items to a dataframe (wraps `to_list()`)"""
return pd.DataFrame(self.to_list())
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work without using a keyword arg? I would expect this to error if called: https://github.com/pandas-dev/pandas/blob/v2.0.3/pandas/core/frame.py#L643

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does! Python is permissive...

>>> def func(a=None, b=None):
...     print(a, b)
...
>>> func('hello')
hello None
>>> func('hello', 'world')
hello world
>>> func(b='hello', a='world')
world hello

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh. I guess it's just putting non kwargs after kwargs that it doesn't like!

tests/resources/test_stream.py Show resolved Hide resolved
runeq/resources/stream.py Outdated Show resolved Hide resolved
@cranti cranti requested a review from maxmora August 15, 2023 17:54
@cranti cranti merged commit 6b1ecb2 into main Aug 16, 2023
8 checks passed
@cranti cranti deleted the sw-2247/datetime branch August 16, 2023 15:04
@cranti cranti mentioned this pull request Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants