I have a pandas dataframe containing song url with '.mp3' file extension. I want to replace '.wav'
Here you can see that, Path column contains the path of the song in the Songs directory. The song has '.mp3' extension. But I want to replace it with '.wav' extension.
How should I do it?
CodePudding user response:
We can try this one :
df['Path'] = df['Path'].str.replace('.mp3', '.wav', regex=False)
And if we want to be sure that we want to change the .mp3 at the end of the string :
df['Path'] = df['Path'].str.replace('.mp3$', '.wav', regex=True)


