-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
BugRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas versionStringsString extension data type and string dataString extension data type and string data
Milestone
Description
The latest version (0.24.1) does not replace comma separator, but 0.23.4 does.
import pandas as pd
df = pd.DataFrame({'one': ["1,000", "2,000"], 'two': ["3,000", "4,000"]})
df = df.replace({',': ''}, regex=True)
print(pd.__version__)
print(df)
0.23.4
one two
0 1000 3000
1 2000 4000
0.24.1
one two
0 1,000 3,000
1 2,000 4,000
If other characters are used with a comma, it works normally
df = df.replace({'1,': ''}, regex=True)
one two
0 000 3,000
1 2,000 4,000
Metadata
Metadata
Assignees
Labels
BugRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas versionStringsString extension data type and string dataString extension data type and string data
Type
Projects
Relationships
Development
Select code repository
Activity
PetitLepton commentedon Feb 11, 2019
Hi, it is not related to commas. In your example @mr-yoo, if you try to replace
,0
, it also fails. The replacement works only if the pattern is the beginning of the stringCan it be related to
in managers.py?
re.match
checks only if the beginning of the string matches. Should it bere.search
? From my tests, it seems to reproduce the previous behaviour.WillAyd commentedon Feb 11, 2019
@PetitLepton seems logical, so maybe introduced as part of #20656
Would certainly welcome a PR to fix if you are up for one