Python_16.ライブラリ/Datetime , Pandas
import datetime
today = datetime.date.today()
datetime.datetime.now()
datetime.datetime(2021, 6, 29, 0, 56, 53, 636589)
today.month
6
today-datetime.timedelta(days=1)
datetime.date(2021, 6, 27)
today.strftime('%Y年%m月%d日')
#stringfortime?
2021年06月28日
today.strftime('%Y/%m/%d')
2021/06/28
--
!pip3 install pandas
#pip3をインストールしていない場合?
import pandas as pd
df=pd.DataFrame([
[1,2,3],
[4,5,6],
[7,8,9]
])
df
df.head()
#頭から五行目まで取得
df.head(3)
df.tail()
df.tail(3)
df.iloc[:,:3]
#:=全て、:3=三列目の一つ前まで取得する(0列目、1列目、2列目)
df.iloc[:,:3].head()
#頭五行?
df['housing_median_age']>30
df[df['housing_median_age']>30]
df.shape
(3000, 9)
df.mean()
#平均値
df.std()
#標準偏差
df.max()
#最大値
df.describe()
#統計量をまとめてみたい