0

I am having a data frame like this

3                1388
4                1388
5                 IBM
8              157.75
9               88929
1021             1500
854                 n
388            157.75
394            157.75
474            157.75
1584            88929
444          20160713
459    93000546718000
461                 7
55     93000552181000
22              89020
400            157.75
361              0.73
981                 0
16    1468416600.6006
18    1468416600.6006
362              0.46

I want to convert this data frame to {3:1388,4:1388,5: IBM,........}

How can i do this?

i am having duplicates in data frame but it has to has to accept

rams
  • 1
  • 1

1 Answers1

1
df = pd.DataFrame({'col1': [1, 2],
                      'col2': [0.5, 0.75]},
                       index=['a', 'b'])



print(df)

   col1  col2
a     1   0.50
b     2   0.75

df.to_dict(){'col1': {'a': 1, 'b': 2}, 'col2': {'a': 0.5, 'b': 0.75}}

This is small example you can try this method

Sociopath
  • 13,068
  • 19
  • 47
  • 75