# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
import numpy as np
from matplotlib.dates import (YEARLY, DateFormatter,
                              rrulewrapper, RRuleLocator, drange, date2num)
from datetime import datetime

# +

df = pd.read_csv(
    "covid-19-get-data\\public\\data\\ecdc\\full_data.csv",
    keep_default_na=False,
    encoding="UTF-8",
    engine='python'
)
df = df.set_index('location')
print(type(df))
print(df)
print('\n..............................................................\n')
print(df.loc[['China']])
print("type of df.loc[['China']]: ", type(df.loc[['China']]))
print('\n..............................................................\n')
print(df.loc['China'])
print("type of df.loc['China']: ", type(df.loc['China']))
print('\n..............................................................\n')

country = ['Taiwan',
           'China',
           'France',
           'Italy',
           'Japan',
           'Philippines',
           'South Korea',
           'Spain',
           'United Kingdom',
           'United States',
           'World']

print(df.loc[country])


df = df.loc['Zimbabwe']
print(type(df))
print(df.shape)
df
# -

df = df.filter(items=['date','new_cases'])
df

print(df.iloc[0,0])
print(df.iloc[0,1])
print(df.iloc[1,1])


df.axes

df.columns

df = pd.read_csv(
    "covid-19-get-data\\public\\data\\ecdc\\full_data.csv",
    keep_default_na=False,
    encoding="UTF-8",
    engine='python'
)
df.location.unique()

country = ['Taiwan',
           'China',
           'France',
           'Italy',
           'Japan',
           'Philippines',
           'South Korea',
           'Spain',
           'United Kingdom',
           'United States',
           'World']
country.sort()
print(country)

# +
df = pd.read_csv(
    "covid-19-get-data\\public\\data\\ecdc\\full_data.csv",
    keep_default_na=False,
    encoding="UTF-8",
    engine='python'
)
print("\n***************start replace*********************\n")



print(df)
print("\n***************end replace***********************\n")

df = df.set_index('location')
df = df.loc[country]
df = df.filter(items=['date','new_cases'])

case_data = []
print(type(df.date))
print(type(df['date']))
print("\n*************************************************\n")

# print("shape of df['date']:", df['date'].shape[0])
# for i in temp_df['date']:
#     i = datetime.strptime(i,'%Y-%m-%d')
#     #print("strptime: ", i)
#     i = [date2num(i)]
#     #print("date2num: ", i)



    
    
print("\n*************************************************\n")
for i , element in enumerate(country):
    temp_df = df.loc[element]
    print(temp_df['date'])
    case_data.extend([[temp_df['date'].tolist(),temp_df['new_cases'].tolist()]])
    
print(np.array(case_data).shape)
print("\n*************************************************\n")
# print(df.loc['Taiwan'])
# print(df.loc['China'])

# print(type(case_data))
# print(type(case_data[0]))
# print(case_data[0][0])
# print(case_data[0][1])
# print(case_data[1][1])
# print(case_data[2][1])

# +
xdata, ydata = [],[]
for i in range(10):
    print("\ni=",i)
    for t in range(len(country)): #iterate every country
        x = case_data[t][0][0:i+1]
        y = case_data[t][1][0:i+1]
#         print("y:",y,"\n")
        #print("x:",([date2num([datetime.strptime(x[0],'%Y-%m-%d')])[0].tolist()]))
        #xdata.append([date2num([datetime.strptime(x[0],'%Y-%m-%d')])[0].tolist()])
        xdata.append(x)
        print(type(y))
        ydata.append(y)
        print(x,y)
    print("xdata:",xdata,"\nydata:", ydata)
        
print(xdata)
print(type(xdata[0]))

StarcoderdataJupyterScriptsDedupFiltered