-1

Any idea why pandas dataframe append is inserting NaN values for only 3 columns out of 50 columns where as dictionary has the real value

checking whether dict has proper values or not before appending, its shows real values:

 for x,y in dict.items():
     print(x, '-', y)

but after appending to dataframe its showing as NaN, no clue why its happening.

df = df.append(dict,ignore_index=True,sort=False)

Any idea where its going wrong ?

2 Answers2

0

The dict must be a dataframe or series

DataFrame.append(df, dict, ignore_index=False, verify_integrity=False, sort=None)
Petronella
  • 2,327
  • 1
  • 15
  • 24
  • dict is a dictionary in my case. i am able to append the data successfully with dictionary... only 3 columns are reflecting as NaN out of 50 columns – hariram manohar Jan 02 '20 at 12:11
  • 1
    Well, you need to either use dictionaries and then transform them to dataframe, or dataframes and append dataframes. Do not append dictionary to dataframe.... – Petronella Jan 02 '20 at 12:43
  • hope we can append dictionary to dataframe without any issues and its valid right ? https://stackoverflow.com/questions/51774826/append-dictionary-to-data-frame – hariram manohar Jan 03 '20 at 10:24
0

Sorry i wasted a lot of time. i am seeing df.head() and assuming i didnt get the proper data but after seeing df values got inserted properly :)