Skip to content

Incorrect example in wide_to_long docstring #25733

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

Closed
TomAugspurger opened this issue Mar 14, 2019 · 3 comments · Fixed by #26273
Closed

Incorrect example in wide_to_long docstring #25733

TomAugspurger opened this issue Mar 14, 2019 · 3 comments · Fixed by #26273

Comments

@TomAugspurger
Copy link
Contributor

The last example at https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.wide_to_long.html is incorrect.

>>> df = pd.DataFrame({
...     'famid': [1, 1, 1, 2, 2, 2, 3, 3, 3],
...     'birth': [1, 2, 3, 1, 2, 3, 1, 2, 3],
...     'ht_one': [2.8, 2.9, 2.2, 2, 1.8, 1.9, 2.2, 2.3, 2.1],
...     'ht_two': [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9]
... })
>>> df
>>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age',
                        sep='_', suffix='\w')
>>> l

locally, l is an empty dataframe

Empty DataFrame
Columns: [ht_two, ht_one, ht]
Index: []

I think the suffix should be \w+.

@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Mar 14, 2019
@jreback jreback modified the milestones: Contributions Welcome, 0.25.0 Mar 14, 2019
@cmorph1
Copy link

cmorph1 commented Apr 5, 2019

Hi, Is this still open?

@WillAyd
Copy link
Member

WillAyd commented Apr 6, 2019

@cmorph1 it is still open. There was a PR against it which may have been stalled (no updates in over 2 weeks) so feel free to pick up where that left off

@cmorph1
Copy link

cmorph1 commented Apr 6, 2019

@WillAyd has sanjusci fixed the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment