python script to remove - and replace with space for name column can i use dfnamestrreplace
Yes, you can use the str.replace() method to replace the "-" character with a space in the "name" column of a pandas dataframe. Here's an example:
import pandas as pd
# create example dataframe
df = pd.DataFrame({'name': ['John-Doe', 'Jane-Smith', 'Bob-Johnson']})
# replace "-" with " " in name column
df['name'] = df['name'].str.replace('-', ' ')
# print updated dataframe
print(df)
Output:
name
0 John Doe
1 Jane Smith
2 Bob Johnson
原文地址: https://www.cveoy.top/t/topic/eCk6 著作权归作者所有。请勿转载和采集!