example: I want to convert all values under the column item price at once so that they do not have the '$' sign.
order_id item_price
0 $2.39
1 $3.39
2 $3.39
3 $2.39
4 $16.98
You can see the pandas documentation.
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.replace.html https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html#pandas.to_numeric
https://datatofish.com/string-to-integer-dataframe/
I did this example in my head without test: pd.to_numeric(your_df.price.str.replace("$", ""))
try this
for i in range(0,len(df)):
df['columnname'][i] = df['columnname'][i].replace('$',' ')
df
or faster way maybe
df.columnname = [x.replace('$',' ') for x in df.columnname]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.