@EdChum的答案很聪明,效果很好。但是,既然有多种方法可以烤蛋糕……为什么不使用正则表达式呢?例如:
df[df.columns[1:]] = df[df.columns[1:]].replace('[$,]', '', regex=True).astype(float)对我来说,这更具可读性。

@EdChum的答案很聪明,效果很好。但是,既然有多种方法可以烤蛋糕……为什么不使用正则表达式呢?例如:
df[df.columns[1:]] = df[df.columns[1:]].replace('[$,]', '', regex=True).astype(float)对我来说,这更具可读性。