Skip to content

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

Merged
merged 15 commits into from
Nov 20, 2019
Merged

CLN: reshape #29627

merged 15 commits into from
Nov 20, 2019

Conversation

jbrockmendel
Copy link
Member

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

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
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 play nice with subclassing?

Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

should deprecate / remove this

Copy link
Contributor

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

Copy link
Contributor

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 = (
Copy link
Contributor

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(...))

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

use enumerate

@jreback jreback added Clean Typing type annotations, mypy/pyright type checking Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Nov 16, 2019
@jreback jreback added this to the 1.0 milestone Nov 16, 2019
@@ -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
Copy link
Member

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

@@ -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]:
Copy link
Member

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

@@ -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
Copy link
Contributor

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
Copy link
Contributor

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

@jreback jreback merged commit 002a89c into pandas-dev:master Nov 20, 2019
@jreback
Copy link
Contributor

jreback commented Nov 20, 2019

thanks, if you can create an issue for that deprecation

@jbrockmendel jbrockmendel deleted the cln-reshape branch November 20, 2019 15:35
jacobaustin123 pushed a commit to jacobaustin123/pandas that referenced this pull request Nov 20, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Reshaping Concat, Merge/Join, Stack/Unstack, Explode Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants