to
list of tuples
list(df.itertuples(index=False, name=None))
check type count in col
df['col1'].apply(lambda x: type(x)).value_counts()
df['col1'][df['col1'].apply(lambda x: isinstance(x,str))]
df['col1'].dt.year.value_counts().sort_index()
dict of list
df.groupby('key')['val'].apply(list).to_dict()
df.groupby('key')[['va1','va2']].apply(lambda g: g.values.tolist()).to_dict()
df to dic
#each col to a key
df = pd.DataFrame({'a': [1,2],'b': ['x', 'y'], 'c': ['u', 'v']})
dic = df.to_dict('list')
#each row to a key
df = pd.DataFrame({'id': ['p', 'q', 'r'],'a': ['red', 'yellow', 'blue'], 'b': [0.5, 0.25, 0.125]})
dic = df.set_index('id').T.to_dict('list')
#not work
dic = {k: list(g) for k, g in df.groupby('id')['a','b']}
#series: id is key, a and b are in 2d array
xx = df.groupby('id').apply(lambda x:x[['a','b']].values)
#series: similar to previous, values col has a name
yy = df.groupby('id')['a','b'].apply(lambda x: x.values.tolist()).to_frame('val').reset_index()