I'm trying to create a DataFrame with an append:
col_stats= ['Attribute', 'Mean', 'Var', 'Std']
stats = pd.DataFrame(columns=[col_stats])
for i in train:
new_row = [
i,
train[i].mean(),
np.var(train[i]),
np.nanstd(train[i])
]
new_row = pd.Series(new_row)
stats = stats.append(new_row, ignore_index=True)
stats
It works when I eliminate this line:
stats = stats.append(new_row, ignore_index=True)
If not, It gives me this error:
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
The 'Attribute' columns is a string (the name of the variable). The other columns (Mean, Var, Std) are numbers (integers, floats)
Why can I not use pd.df.append here?
new_row = pd.DataFrame(new_row, columns=col_stats)train.describe().T?