pythonのpandasは意外と機能充実してる
pythonのpandasにはSeriesやDataFrameなどがあるが,numpyを使わずとも意外とそれだけれ色々できることがあったのでメモ
import pandas as pd df = pd.DataFrame({ "col1": [1, 2, 3, 4, 5], "col2": [10, 20, 30, 40, 50] }) print(df) # col1 col2 # 0 1 10 # 1 2 20 # 2 3 30 # 3 4 40 # 4 5 50
機能の一部だがこのような使い方ができる
print(df.col1.max()) # 5 print(df.col1.min()) # 1 print(df.col1.mean()) # 3 print(df.col1.std()) # 1.58113883008 print(df.col1 + df.col2) # 0 11 # 1 22 # 2 33 # 3 44 # 4 55 # dtype: int64 print(df.col1 * df.col2) # 0 10 # 1 40 # 2 90 # 3 160 # 4 250 # dtype: int64 print(df.col2.count()) # 5 print(df.col2.value_counts()) # 30 1 # 20 1 # 10 1 # 50 1 # 40 1 # Name: col2, dtype: int64
numpyとか自分で書く前にググるといいかもね
参考として公式refのっけとく