0

I have a data frame where few of columns have mixed type values string + float and when I'm writing them to_excel getting this notification after writing in excel enter image description here

this is the dataframe

df = placementsummaryfinalnew.loc[:,["Placement# Name","PRODUCT","Engagements Rate",
                                                                "Viewer CTR","Engager CTR","Viewer VCR",
                                                                "Engager VCR","Interaction Rate","Active Time Spent"]]

I tried to convert them by using few of lines

placementvdxsummaryfirst["Viewer VCR"] = placementvdxsummaryfirst["Viewer VCR"].astype(object)

its not working

then I tried this one.

placementvdxsummaryfirst["Viewer VCR"] = placementvdxsummaryfirst["Viewer VCR"].astype(float)

its giving error

then I tried this one.

placementvdxsummaryfirst['Viewer VCR'] = pd.to_numeric(placementvdxsummaryfirst['Viewer VCR'],errors='coerce')

its working but its replacing the "N/A" values with blanks which I don't want.

Kindly help.

DKM
  • 1,761
  • 2
  • 19
  • 34

1 Answers1

0

Try:

placementvdxsummaryfirst["Viewer VCR"] = placementvdxsummaryfirst["Viewer VCR"].astype(str)
Rakesh
  • 81,458
  • 17
  • 76
  • 113