0

Hi I want to append dictionary to DataFrame, but in this dictionary I dont have any index value. I also need to remove everything except "1393" from 'KP' value. This looks like this:

To this df:enter image description here

I want to append dictionary like this:

dict = {'KP': [1.0    1393
  Name: KP, dtype: int64],
 'Wiek': [Timedelta('176 days 12:59:43.042156102')],
 'KY1': [113.0],
 'OKO': [57.51],
 'GS': [10.59],
 'T': [654.31],
 'MP': [58.9]}

I try this:

df.append(dict,ignore_index=True)

But nothing happend, df is still the same and i dont get any error. I try to convert this dictionary to list and append list as row to df but I got the same result.

Ok i try this:

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

I get this output: enter image description here

This is not good enought i need clear data.

Park
  • 1,924
  • 1
  • 15
  • 19
maciej.o
  • 39
  • 8
  • Use `df = df.append(dict, ignore_index = True)`. – Vishal A. Jan 28 '22 at 08:07
  • 1
    You can convert the dictionary into a dataframe: `df1 = pd.DataFrame(dict)` and then append: `df = df.append(df1, ignore_index = True)`. Btw using `dict` as a variable name is highly non-recomended as dict is a built-in keyword; also please never post images of dataframes, post them as text as explained in here: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – piterbarg Jan 28 '22 at 08:51
  • Ok thanks that realy help me – maciej.o Jan 28 '22 at 10:01

0 Answers0