I am trying to replace the Nan values with empty strings. This is the code I have
df.replace({r'[^\x00-\x7F]+': ''}, regex=True, inplace=True)
col_buyername = basicinfo.get('buyer_name')
col_product = basicinfo.get('product_name')
col_quantity = basicinfo.get('quantity')
col_price = basicinfo.get('price')
print(df[col_buyername])
df.loc[:, [col_buyername, col_product]].fillna("", inplace=True)
print('after')
print(df[col_buyername])
the output is
0 NaN
1 Roy Thomas
2 NaN
3 NaN
Name: buyer name, dtype: object
after
0 NaN
1 Roy Thomas
2 NaN
3 NaN
Name: buyer name, dtype: object
Why is the fillna nothing setting it to be blank strings?
NaNmeansNot a Number. it isfloat, notstr. You can't put string to a floatdf.fillna('', inplace=True)it was workingdf =df[[col_buyername, col_product, col_address]].fillna("", inplace=True). Adddf =and problem is solved (probably)df[df[[col_buyername, col_product, col_address]].isna()] = ""I got errorTypeError: Cannot do inplace boolean setting on mixed-types with a non np.nan value