Shi Jie Tio
Shi Jie Tio

Reputation: 2529

How to replace 0 to null value in dataframe pandas?

I have a dataframe, some of the cell in the dataframe have 0 , how to replace all the 0 with ' ' ?

final = final.replace(0, '')

This code not able run...Anyone can share me idea?

Upvotes: 2

Views: 21282

Answers (1)

jezrael
jezrael

Reputation: 862801

I think you need:

final = final.replace(0, np.nan)
              .style.apply(color, axis=None)
              .set_table_attributes('border="" class = "dataframe table table-hover table-bordered"')
              .set_precision(10)
              .render() 

Upvotes: 5

Related Questions