-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: reshape #29627
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
CLN: reshape #29627
Conversation
return cons(mgr, name=name).__finalize__(self, method="concat") | ||
|
||
# combine as columns in a frame | ||
else: | ||
data = dict(zip(range(len(self.objs)), self.objs)) | ||
cons = _get_series_result_type(data) | ||
cons = DataFrame |
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.
does this play nice with subclassing?
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.
?
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.
probably not, but its the exact behavior we currently have
@@ -129,6 +131,8 @@ def lreshape(data, groups, dropna=True, label=None): | |||
groups : dict | |||
{new_name : list_of_columns} | |||
dropna : boolean, default True | |||
label : object, default None |
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.
should deprecate / remove this
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.
can you create an issue
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.
can you create an issue to deprecate this
# get left & right join labels and num. of levels at each location | ||
llab, rlab, shape = map(list, zip(*map(fkeys, left_keys, right_keys))) | ||
mapped = ( |
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.
can use enumerate here instead of range(len(...))
pandas/core/reshape/merge.py
Outdated
mapped = (fkeys(index.levels[n], join_keys[n]) for n in range(len(index.levels))) | ||
mapped = ( | ||
_factorize_keys(index.levels[n], join_keys[n], sort=sort) | ||
for n in range(len(index.levels)) |
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.
use enumerate
pandas/core/reshape/concat.py
Outdated
@@ -541,7 +537,7 @@ def _get_concat_axis(self): | |||
idx = ibase.default_index(len(self.objs)) | |||
return idx | |||
elif self.keys is None: | |||
names = [None] * len(self.objs) | |||
names = [None] * len(self.objs) # type: list |
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.
At least for now should always prefer typing.*
to the builtin containers
pandas/core/reshape/melt.py
Outdated
@@ -412,14 +416,14 @@ def wide_to_long(df, stubnames, i, j, sep: str = "", suffix: str = r"\d+"): | |||
two 2.9 | |||
""" | |||
|
|||
def get_var_names(df, stub, sep, suffix): | |||
def get_var_names(df, stub: str, sep: str, suffix) -> List[str]: |
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 think can annotation suffix as a str
pandas/core/reshape/concat.py
Outdated
@@ -537,7 +538,7 @@ def _get_concat_axis(self): | |||
idx = ibase.default_index(len(self.objs)) | |||
return idx | |||
elif self.keys is None: | |||
names = [None] * len(self.objs) | |||
names = [None] * len(self.objs) # type: List |
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.
can you new typing format
@@ -129,6 +131,8 @@ def lreshape(data, groups, dropna=True, label=None): | |||
groups : dict | |||
{new_name : list_of_columns} | |||
dropna : boolean, default True | |||
label : object, default None |
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.
can you create an issue
thanks, if you can create an issue for that deprecation |
I think some of this can be made easier to reason about (like with making FrameApply less stateful), as a preliminary this is just some mild annotations etc