Series
plot
2つめのy軸を用意する
secondary_yを使う
ax = df["A"].plot(secondary_y=True, color="blue", marker="o")
dataframeのplotで、各カラムに色をつける
import pandas as pd import matplotlib.pyplot as plt df = pd.DataFrame([[0, 1, 2], [0, 1, 2]], columns=['red zero line', 'blue one line', 'extra']) df.plot(kind="bar",color=["blue","red"]) plt.show()
dictからdataframeに
ipdb> data = pd.DataFrame(new,index=male2.index)
dataframeのindexにapplyを適用したい。(dataframeにindexの各要素を変更)
df.index.map(str.lower)
plotしたxラベルの角度をかえる
for label in ax.get_yticklabels():↲ label.set_rotation(90) #ラベルの角度
ソート
valueでソート:sort_values,
indexでソート:sort_index
DataFrame
各要素がいくつあるか
df['test'].value_counts().head(10)
特定の値を持つ行の削除
df = df[df["test"]!="aaa"]
特定の値を持つデータの抽出
df = df[df["test"].isin(["aaa"])]