I have to turn all the items in dataframe into string and i have tried as below,
JavaScript
x
2
1
df = df.applymap(str)
2
but it turns nan to string. How can i avoid nan to string here?
i tried as below, but not working.
JavaScript
1
2
1
df.where(~df.notna(),df.applymap(str))
2
Edit i tried df.applymap(str) but some reason i am getting boolean value of NA is ambiguous with my dataframe so i am opting only df.applymap(str)
Advertisement
Answer
You may try :
JavaScript
1
2
1
df = df.fillna('').astype(str)
2
Or you can have a look at this post.