February 2024
Intermediate to advanced
576 pages
9h 17m
Japanese
効率的な要約は、多くのデータ分析作業における基本です。すなわち、巨大なデータセットの何らかの側面を1つの値で表すsum(合計)、mean(平均値)、median(中央値)、min(最小値)、max(最大値)などの集約値の計算です。この章では、NumPy配列で行った単純な操作から、groupbyの概念に基づくより洗練された操作まで、pandasの集約について説明します。
便宜上、前の章で使用したDisplayクラスを再利用します。
In [1]: import numpy as np
import pandas as pd
class Display:
"""HTML表現で複数オブジェクトを表示する"""
template = """<div style="float: left; padding: 10px;">
<p style='font-family:"Courier New", Courier, monospace'>{0}{1}
"""
def __init__(self, *args):
self.args = args
def _repr_html_(self):
return '\n'.join(self.template.format(a, eval(a)._repr_html_())
for a in self.args)
def __repr__(self):
return '\n\n'.join(a + '\n' + repr(eval(a))
for a in self.args)
ここでは、seabornパッケージ(https://seaborn.pydata.org/)の一部として入手できるplanetsデータセットを使用します( ...