-
Notifications
You must be signed in to change notification settings - Fork 1
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
initialize nestedframe #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Please see some suggestions
src/nested_pandas/__init__.py
Outdated
@@ -1,4 +1,5 @@ | |||
from .example_module import greetings, meaning | |||
from .nestedframe import NestedFrame # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove noqa
and add to __all__
?
@@ -0,0 +1 @@ | |||
from .core import * # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need star-import here? It would add pd
and other stuff we don't really need
"""returns a dictionary of columns for each base/nested dataframe""" | ||
all_columns = {"base": self.columns} | ||
for column in self.columns: | ||
if hasattr(self[column], "nest"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would check column's dtype instead, it should be NestedDtype
. No code suggestion here, because we need to import it first
from nested_pandas import NestedDtype
if isinstance(self[column].dtype, NestedDtype):
all_columns = {"base": self.columns} | ||
for column in self.columns: | ||
if hasattr(self[column], "nest"): | ||
nest_cols = self[column].iloc[0].columns # TODO: Improve access to columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nest_cols = self[column].iloc[0].columns # TODO: Improve access to columns | |
nest_cols = self[column].nest.fields() |
"""retrieves the base column names for all nested dataframes""" | ||
nest_cols = [] | ||
for column in self.columns: | ||
if hasattr(self[column], "nest"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if hasattr(self[column], "nest"): | |
if isinstance(self[column].dtype, NestedDtype): |
else: | ||
return False | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a matter of taste, but I believe we don't need these else:
s here
Thanks for the comments, I've addressed them all in the latest commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
Initializes the NestedFrame module. Adds a few properties and an initial add_nested function.