Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas pivot

>>> df = pd.DataFrame({'foo': ['one', 'one', 'one', 'two', 'two',
...                            'two'],
...                    'bar': ['A', 'B', 'C', 'A', 'B', 'C'],
...                    'baz': [1, 2, 3, 4, 5, 6],
...                    'zoo': ['x', 'y', 'z', 'q', 'w', 't']})
>>> df

>>df.pivot(index='foo', columns='bar', values=['baz', 'zoo'])
bar  A   B   C
foo
one  1   2   3
two  4   5   6
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #pandas #pivot
ADD COMMENT
Topic
Name
6+2 =