1

Please help me I have base: https://github.com/devsar/d3talk/blob/master/airports.csv

I create dictionary:

df2 = df[['ident','municipality']]
df2.set_index('ident').T.to_dict('list')

In the dictionary I have square brackets, how to throw it out? enter image description here How to wipe-out square brackets from dictionary?

Wojciech Moszczyński
  • 2,275
  • 16
  • 23

1 Answers1

3

I beleive you need create Series by DataFrame.set_index with select column after and convert to dict:

d = df.set_index('ident')['municipality'].to_dict()
jezrael
  • 729,927
  • 78
  • 1,141
  • 1,090