dictionary from two columns pandas

Solutions on MaxInterview for dictionary from two columns pandas by the best coders in the world

showing results for - "dictionary from two columns pandas"
Alessio
25 May 2018
1pd.Series(df.A.values,index=df.B).to_dict()
Alex
26 Jul 2017
1In [9]: pd.Series(df.Letter.values,index=df.Position).to_dict()
2Out[9]: {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'}
3
Irene
08 Jun 2018
1In [6]: df = pd.DataFrame(randint(0,10,10000).reshape(5000,2),columns=list('AB'))
2
3In [7]: %timeit dict(zip(df.A,df.B))
41000 loops, best of 3: 1.27 ms per loop
5
6In [8]: %timeit pd.Series(df.A.values,index=df.B).to_dict()
71000 loops, best of 3: 987 us per loop
queries leading to this page
pandas two columns to dictmake dictionary from two columns pandashow to turn two dataframe column into dictionarydictionary from 2 pandas columnsconvert 2 columns to dictionary pandaspython how to create dict from dataframe based on 2 columns2 columns of df to dictcreate a dictionary from two columns pandasdictionary using two seriespandas dataframe to dict two columnscreate dictionary from two columns pandas extract column from dataframe and convert to dictionary python2 column dataframe to dictionarycolumn to dict pandas colnamespandas 2 columns to dictpython create dictionary from two columnsconvert pandas 2 columns to dictionarydataframe columns to dictionarypython make dictionary out of two columns in dataframecreate dictionary from two pandas columnstwo columns sf to dict pythontwo pandas columns to dict2 columns to dictdictionary from two columns pandascreate dictionary from 2 columns pandasdf to dict two columnspandas faster way to make a dict of two columnsturn two columns of dataframe to dictpandas column read as dicthow to create a dictionary from two columns in pandas dataframepython create a dictionary from two columnshow to take 2 columns from a dataframe and make a dictionarypandas dataframe to dictionary two columnscreate dict from 2 pandas columnspython dict from two columns pandascreate dictionary from two series pandasdict from two columns pandastransform 2 columns in dict pandascreate dict based on two columns pandaspandas make one column as dict key and another valuedataframe to dictionary with one column as keyconvert pandas dataframe 2 columns to dictionarypandas create dictionary from multiple columnsturn dataframe to dict two columnscreate dictionary with two columns pandastwo columns to dictionary pandasmake df 2 columns to dictpandas convert two columns to dictionarytwo columns in dataframe to dictionarycreate dict from two columns pandaspandas create dictionary from two columns2 columns to dict pandastwo columns pandas to dictmake a dictionary from two columns pandastwo columns pandas to dictioanry2 columns to dictionary pandasdf two columns to dictionarycreating a dictionary with two seriesdictionary using 2 columnsdictionary from two columns pandas