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

series.str.extract does not work for timeseries #6348

Closed
andrewkittredge opened this issue Feb 14, 2014 · 6 comments
Closed

series.str.extract does not work for timeseries #6348

andrewkittredge opened this issue Feb 14, 2014 · 6 comments
Labels
Bug Strings String extension data type and string data
Milestone

Comments

@andrewkittredge
Copy link
Contributor

series.str.extract does not work for time-series because core.strings.str_extract does not preserve the index. I am submitting a unittest and patch that demonstrates and hopefully fixes the issue.

@andrewkittredge
Copy link
Contributor Author

apparently duplicated by my pull request.

@jreback
Copy link
Contributor

jreback commented Feb 17, 2014

when I merge your PR this will close automatically

@jreback
Copy link
Contributor

jreback commented Feb 23, 2014

closed via 8efa4ac

@patricksurry
Copy link

Got bitten by this - it also silently gives the wrong answer if you've made a selection on a default index (example below). Work around is to explicitly reset_index(drop=True) before using str.extract.

print pd.__version__
df = pd.DataFrame([
    {'a': 'quick', 'b': 0}, 
    {'a': 'brown', 'b': 1}, 
    {'a': 'fox', 'b': 0},
    {'a': 'jumped', 'b': 1}
])
print df
df2 = df[df.b == 1]
df2['b'] = df2.a.str.extract('(p)')
print df2

output:

0.13.1
        a  b
0   quick  0
1   brown  1
2     fox  0
3  jumped  1

[4 rows x 2 columns]
        a    b
1   brown    p
3  jumped  NaN

[2 rows x 2 columns]

@jreback
Copy link
Contributor

jreback commented May 18, 2014

this was fixed for 0.14.0

0.14.0rc1 was just released, see here: https://groups.google.com/forum/m/#!topic/pydata/Bx8oiSAZwOc

@patricksurry
Copy link

Yup, thanks, I saw it was closed already, but I just wanted to leave a trail in case anyone else ran into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants