I have this dataframe:
symbol date open high low close volume
0 BTC/USDT 2020-03-28 00:00:00 00:00 6243.25 6298.5 6028.0 6237.5 3.888942e 03
1 BTC/USDT 2020-03-29 00:00:00 00:00 6233.50 6262.5 5869.5 5876.5 1.140766e 05
2 BTC/USDT 2020-03-30 00:00:00 00:00 5876.00 6609.0 5856.0 6396.5 2.242312e 05
3 BTC/USDT 2020-03-31 00:00:00 00:00 6397.00 6523.5 6330.5 6411.0 1.702458e 05
4 BTC/USDT 2020-04-01 00:00:00 00:00 6410.00 6685.5 6155.5 6646.0 6.872307e 05
.. ... ... ... ... ... ... ...
599 BTC/USDT 2021-11-17 00:00:00 00:00 60060.00 60820.0 58347.0 60348.0 1.627009e 08
600 BTC/USDT 2021-11-18 00:00:00 00:00 60348.00 60955.0 56474.0 56891.0 1.905533e 08
I need to replace the "/" in the symbol column with "-".
Code I have tried:
df['symbol'] = df['symbol'].replace(['/'], '-')
df['symbol'] = df['symbol'].replace(['/'], '-', inplace=True)
df['symbol'] = df.replace('/', '-')
df = df.replace(to_replace='\/', value='-', regex=True)
I know it's something simple, but I'm not getting it.
CodePudding user response:
You should use str
:
df['symbol'] = df['symbol'].str.replace('/', '-')