Answers for "pivot table pandas"

1

pd.pivot_table

>>> table = pd.pivot_table(df, values=['D', 'E'], index=['A', 'C'],
...                     aggfunc={'D': np.mean,
...                              'E': [min, max, np.mean]})
>>> table
                D    E
            mean  max      mean  min
A   C
bar large  5.500000  9.0  7.500000  6.0
    small  5.500000  9.0  8.500000  8.0
foo large  2.000000  5.0  4.500000  4.0
    small  2.333333  6.0  4.333333  2.0
Posted by: Guest on June-07-2020
0

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
Posted by: Guest on May-23-2021
0

Pandas pivot table

>>> emp.pivot_table(index='dept', columns='gender',                     values='salary', aggfunc='mean').round(-3)
Posted by: Guest on August-09-2021
0

pivot table pandas

df.pivot_table(['int_age'],index = [df.iloc[:,meet_friends], df.iloc[:,friendsgiving]])
Posted by: Guest on April-12-2021
0

pivot table pandas

df.pivot_table(index = [df.iloc[:,meet_friends], df.iloc[:,friendsgiving]])
Posted by: Guest on April-12-2021
-1

pivot table pandas

# Tips is the Dataframe:
# Suppose we want to compute a table of group means, we can
# use the Pivot_Table Method:

# The Pivot Table automatically computes the mean

tips.pivot_table(index=['day', 'smoker'])

# The index represents the column names that you want to form groups
Posted by: Guest on April-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language