-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: not correct work str.split #43563
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
Comments
I can confirm this on master, and I think should work given it works on In [23]: 'qweqwejpgqweqwe.jpg'.split(".jpg")[0]
Out[23]: 'qweqwejpgqweqwe' For your case, you can add an escape character and it should work ( In [1]: import pandas as pd
...:
...: df = pd.DataFrame(columns=['url'])
...: df['url'] = ['https://qweqwe.com/2021-09-14/qweqwejpgqweqwe.jpg']
...: df['id'] = df['url'].str.split('/').str[-2].astype(str) + '_' + df['url'].str.split('/').str[-1].str.split('\.jpg').str[0]
...: print(df['id'].iloc[0])
...:
2021-09-14_qweqwejpgqweqwe |
maybe the documentation could be improved here, but with OR an enhancement to include a pandas/pandas/core/strings/object_array.py Lines 311 to 326 in 0a9f9ee
|
also see related : #37963 |
I like the idea of adding a |
take |
Thank you @mzeitlin11 for your prompt reply. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
output: 2021-09-14_qweqw
true output: 2021-09-14_qweqwejpgqweqwe
Expected Behavior
2021-09-14_qweqwejpgqweqwe
Installed Versions
python 3.9
pandas version 1.3.2
The text was updated successfully, but these errors were encountered: