Open roberthsu2003 opened 3 weeks ago
日本 | 台灣 |
---|---|
import numpy as np
import pandas as pd
df1 = pd.read_csv('world.csv')
df2 = df1.reindex(columns=['洲名','國家','日期','總確診數','新增確診數'])
df3= df2.query ('國家=="台灣" | 國家=="日本"')
t_j_2021_01_df = df3. query('日期>="2021-01-01" and 日期<="2021-01-31"')
t_j_2021_01_df.to_csv('t_j_2021_01.csv',index=False)
t_j_2021_01_df.to_excel('t_j_2021_01.xlsx',index=False,sheet_name='2021_01')
t_j_2021_01_df.to_json('t_j_2021_01.json',orient='table',force_ascii=False)
import numpy as np
import pandas as pd
df1 = pd.read_csv('world.csv')
df2 = df1.reindex(columns=['洲名','國家','日期','總確診數','新增確診數'])
df3 = df2.query('日期>="2021-01-01" and 日期<="2021-01-31"and 國家==["台灣","日本"]')
df3.to_csv('TWJP202101.csv',index=False)
df3.to_excel('TWJP202101.xlsx',index=False,sheet_name='2021-01')
df3.to_json('TWJP202101.json',orient='table',force_ascii=False)
import numpy as np
import pandas as pd
df1 = pd.read_csv('world.csv')
df2 = df1.reindex(columns=['洲名','國家','日期','總確診數','新增確診數'])
tw_jp_df = df2.query('日期>="2021-01-01" and 日期<="2021-01-31" and 國家==["台灣","日本"]')
tw_jp_df.to_csv('tw_jp_202101.csv',index=False)
tw_jp_df.to_excel('tw_jp_202101.xlsx',index=False,sheet_name='202101')
tw_jp_df.to_json('tw_jp_202101.json',orient='table',force_ascii=False)
import numpy as np
import pandas as pd
df1=pd.read_csv('world.csv')
df2=df1.reindex(columns=['洲名','國家','日期','總確診數','新增確診數','總人口數'])
tw_ja_df3=df2.query('國家=="台灣" or 國家=="日本"')
tw_ja_2021jan_df4=tw_ja_df3.query('日期>="2021-01-01" and 日期<="2021-01-31"')
tw_ja_2021jan_df4.to_csv('tw_ja_2021jan_df4.csv',index=False)
tw_ja_2021jan_df4.to_excel('tw_ja_2021jan_df4.xlsx',index=False)
tw_ja_2021jan_df4.to_json('tw_ja_2021jan_df4.json',orient='table',force_ascii=False)
xlsx:
csv:
json:
import pandas as pd
df1 = pd.read_csv('world.csv')
df2 = df1.reindex(columns=['洲名', '國家', '日期', '總確診數', '新增確診數'])
conutry_df = df2.query("國家=='台灣' or 國家=='日本'")
date_df = conutry_df.query('日期>= "2021-01-01" and 日期<= "2021-12-31"')
date_df.to_csv('tw_jp_2021.csv', index=False)
date_df.to_excel('tw_jp_2021.xlsx', index=False, sheet_name='2021')
date_df.to_json('tw_jp_2021.json', orient='table',force_ascii=False)
import numpy as np
import pandas as pd
df1= pd.read_csv('world.csv')
df2 = df1.reindex(columns=['洲名','國家','日期','總確診數','新增確診數'])
twjp_df = df2.query('國家=="台灣" or 國家=="日本"')
twjp202101_df = twjp_df.query('日期>="2021-01-01" and 日期<="2021-01-31"')
twjp202101_df.to_csv('twjp202101.csv',index=False)
twjp202101_df.to_excel('twjp202101.xlsx',index=False,sheet_name='2021')
twjp202101_df.to_json('twjp202101.json', orient='table', force_ascii=False)