我有一個資料集 df,我想在列中用句點替換空格。
資料
Date id
Q1 2022 a
Q2 2022 b
想要的
Date id
Q1.2022 a
Q2.2022 b
正在做
df.apply(lambda x: x.str.replace('','.'))
任何建議表示贊賞
uj5u.com熱心網友回復:
試試
df['Date'] = df['Date'].str.replace(' ', '.', regex=False)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/317000.html
