幾個比較重要的指令
看看DataFrame df相關的資訊
- import pandas as pd
- import matplotlib.pyplot as plt
- df=pd.read_csv('https://od.cdc.gov.tw/eic/covid19/covid19_global_cases_and_deaths.csv')
如果要看台灣的資訊
- df.index
- df.columns
- pd.DataFrame(df, index=[0,1, 7,2,176])
因為資料string必須去掉','並轉換為數字,python的一般作法就是用lambda函數
- s=df[df['country_en']=='Taiwan']
- s
有關死亡人數的資料
- df0=df.apply(lambda x: x.str.replace(',','').apply(pd.to_numeric, errors='ignore'))
- df[df0['deaths']>=10000]
- deaths=df0['deaths']
- print(deaths.describe())
- plt.plot(deaths.to_numpy())
- plt.show()
沒有留言:
張貼留言