Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.