我使用该pandas库编写了以下代码。我想知道是否有办法优化代码。
for column in df:
for index, row in df[column].iteritems():
if type(row) == str:
if 'R$' in row:
n = row.replace('R$', '')
n = n.replace(' ', '')
n = n.replace('.', '')
df[column].iloc[index] = float(n)
只想删除不需要的字符串部分。