Answers for "pandas create dictionary from two columns"

6

dictionary from two columns pandas

pd.Series(df.A.values,index=df.B).to_dict()
Posted by: Guest on September-25-2020
1

python how to create dict from dataframe based on 2 columns

In [9]: pd.Series(df.Letter.values,index=df.Position).to_dict()
Out[9]: {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'}
Posted by: Guest on January-15-2021
0

pandas create dataframe from multiple dictionaries

sales = [{'account': 'Jones LLC', 'Jan': 150, 'Feb': 200, 'Mar': 140},
         {'account': 'Alpha Co',  'Jan': 200, 'Feb': 210, 'Mar': 215},
         {'account': 'Blue Inc',  'Jan': 50,  'Feb': 90,  'Mar': 95 }]
df = pd.DataFrame(sales)
Posted by: Guest on April-04-2021

Code answers related to "pandas create dictionary from two columns"

Python Answers by Framework

Browse Popular Code Answers by Language