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,893
  • 21
  • 27

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
  • 822,522
  • 95
  • 1,334
  • 1,252