You can replace the hyphen character in a column of a data frame with a zero using the str.replace()
method in pandas. Here's an example:
Assuming your data frame is called df
and the column with the hyphen character is called my_column
, you can replace the hyphen with a zero using the following code:
df['my_column'] = df['my_column'].str.replace('-', '0')
This code will replace all occurrences of the hyphen character in the my_column
column with a zero, and store the modified values back in the same column.
Asked: 2023-06-14 00:36:46 +0000
Seen: 15 times
Last updated: Jun 14 '23