I have dataframe (in a matrix form) where each cell is either 0 or {}. I want to replace the {} for 1.
I tried the following:
df.replace({},1)
and
for col in df:
for i, val in enumerate(col):
if df[col][i] == {}:
df[col][i] = 1
Both are not working. There are no errors, just the {} does not get replace. Is there an issue with {} ? I got this matrix by applying pd.DataFrame(some dictionary).
replacewill not work here as it is for strings.