In [1]:
import pandas as pd
from collections import OrderedDict
In [2]:
df = pd.DataFrame({'col1': [1, 2, 3], 'col2': ['a', 'x', 'あ']},
index=['row1', 'row2', 'row3'])
In [3]:
print(df)
In [4]:
s = df['col1']
print(s)
In [5]:
print(type(s))
In [6]:
d = s.to_dict()
print(d)
In [7]:
print(type(d))
In [8]:
s = df.set_index('col2')['col1']
print(s)
In [9]:
d = s.to_dict()
print(d)
In [10]:
od = df['col1'].to_dict(OrderedDict)
print(od)
In [11]:
print(type(od))