Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

display column names as a dictionary pandas

import pandas as pd

df = pd.DataFrame({'date': ['2015-01-01', '2015-01-02', '2015-01-03'],
                   'value': ['a', 'b', 'c'],
                   'num': [1, 2, 3]
                   })

print(df)
print({c: i for i, c in enumerate(df.columns)})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #display #column #names #dictionary #pandas
ADD COMMENT
Topic
Name
5+1 =