I tried to use pandas.DataFrame.replace() to fill empty strings in a frame via the code below.
main_datasets = [train_data, test_data, alt_data1, alt_data2]
for data in main_datasets:
for x in data:
if type(x) == 'int':
x.fillna(x.median(), inplace = True)
elif type(x) == 'float':
x.fillna(x.median(), inplace = True)
else:
x.replace(to_replace = None, value = 'N/A', inplace = True)
However, I continue to receive the following exception, despite using characters or numbers for the keyword value and removing the keyword name:
TypeError: replace() takes no keyword arguments
Why is this error raised from "value = 'N/A?'"
Here is an ad hoc sample of some fields (separated by commas):
12123423, 0, M, Y, 120432.5
12654423, 1, F, N, 80432.5
12123423, 0, M, Y, 120432.5
12123423, 0, M, Y, 120432.5