Series.replace Not Working With Regex For Pandas > 1.0.5
I am trying to use the next code in order to replace the date part of the index column with the value of the some_date: input_dict = { '2019-08-08|some_col1': {'some_date':
Solution 1:
Alternative:
df["index"] = df.apply(lambda sr: re.sub(r'\d{4}-\d{2}-\d{2}', sr["some_date"],
sr["index"]), axis="columns")
>>> df
0 2019-08-18|some_col1
1 2019-08-19|some_col2
2 2019-08-20|some_col3
dtype: object
Post a Comment for "Series.replace Not Working With Regex For Pandas > 1.0.5"