Pandas
是数据挖掘常见的工具,掌握使用过程中的函数是非常重要的。本文将借助可视化的过程,讲解Pandas
的各种操作。
(dogs[dogs['size'] == 'medium']
.sort_values('type')
.groupby('type').median()
)
执行步骤:
dogs['longevity']
dogs.groupby('size').mean()
执行步骤:
dogs.groupby(['type', 'size'])
(dogs
.sort_values('size')
.groupby('size')['height']
.agg(['sum', 'mean', 'std'])
)
执行步骤
df.loc[:, df.loc['two'] <= 20]
dogs.loc[(dogs['size'] == 'medium') & (dogs['longevity'] > 12), 'breed']
dogs.drop(columns=['type'])
ppl.join(dogs)
ppl.merge(dogs, left_on='likes', right_on='breed', how='left')
dogs.pivot_table(index='size', columns='kids', values='price')
dogs.melt()
dogs.pivot(index='size', columns='kids')
dogs.stack()
dogs.unstack()
dogs.reset_index()
dogs.set_index('breed')