Update Readme.md

parent 761ce2f2
......@@ -201,3 +201,70 @@ data = data_raw
MARKDOWN : "Une fois nos données disponibles, je vais chercher les lignes des pays nous intéressant avec la fonction `.loc()` de la bibliothèque Pandas. Une fois ces données localisées, je vais les regrouper sous forme de DataFrame afin de pouvoir les traiter."
Pour avoir le `.loc()` écrire ``<code>.loc()</code>``
Nous pouvons maintenant extraire les données pour chaque pays. Pour cela, il faut tout d'abord les localiser avec la fonction `.loc()` en écrivant le code suivant :
```
Row_Belgium = data.loc[data['Country/Region'] == 'Belgium']
Series_Belgium = pd.Series(data.loc[Row_Belgium.index[0]], name = 'Belgium', dtype = int)
Row_China = data.loc[(data['Country/Region'] == 'China') & (data['Province/State'] != 'Hong Kong')]
Series_China_Total = Row_China.sum()
Row_HongKong = data.loc[data['Province/State'] == 'Hong Kong']
Series_HongKong = pd.Series(data.loc[Row_HongKong.index[0]], name = 'HongKong', dtype = int)
Row_France = data.loc[(data['Province/State'].isna()) & (data['Country/Region'] == 'France')]
Series_France = pd.Series(data.loc[Row_France.index[0]], name = 'France', dtype = int)
Row_Germany = data.loc[data['Country/Region'] == 'Germany']
Series_Germany = pd.Series(data.loc[Row_Germany.index[0]], name = 'Germany', dtype = int)
Row_Iran = data.loc[data['Country/Region'] == 'Iran']
Series_Iran = pd.Series(data.loc[Row_Iran.index[0]], name = 'Iran', dtype = int)
Row_Italy = data.loc[data['Country/Region'] == 'Italy']
Series_Italy = pd.Series(data.loc[Row_Italy.index[0]], name = 'Italy', dtype = int)
Row_Japan = data.loc[data['Country/Region'] == 'Japan']
Series_Japan = pd.Series(data.loc[Row_Japan.index[0]], name = 'Japan', dtype = int)
Row_KoreaSouth = data.loc[data['Country/Region'] == 'Korea, South']
Series_KoreaSouth = pd.Series(data.loc[Row_KoreaSouth.index[0]], name = 'Korea, South', dtype = int)
Row_Netherlands = data.loc[(data['Province/State'].isna()) & (data['Country/Region'] == 'Netherlands')]
Series_Netherlands = pd.Series(data.loc[Row_Netherlands.index[0]], name = 'Netherlands', dtype = int)
Row_Portugal = data.loc[data['Country/Region'] == 'Portugal']
Series_Portugal = pd.Series(data.loc[Row_Portugal.index[0]], name = 'Portugal', dtype = int)
Row_Spain = data.loc[data['Country/Region'] == 'Spain']
Series_Spain = pd.Series(data.loc[Row_Spain.index[0]], name = 'Spain', dtype = int)
Row_UnitedKingdom = data.loc[(data['Province/State'].isna()) & (data['Country/Region'] == 'United Kingdom')]
Series_UnitedKingdom = pd.Series(data.loc[Row_UnitedKingdom.index[0]], name = 'United Kingdom', dtype = int)
Row_US = data.loc[data['Country/Region'] == 'US']
Series_US = pd.Series(data.loc[Row_US.index[0]], name = 'US', dtype = int)
frame = {'Belgium': Series_Belgium,
'China': Series_China_Total,
'Hong Kong': Series_HongKong,
'France': Series_France,
'Germany': Series_Germany,
'Iran': Series_Iran,
'Italy': Series_Italy,
'Japan': Series_Japan,
'Korea, South': Series_KoreaSouth,
'Netherlands': Series_Netherlands,
'Portugal': Series_Portugal,
'Spain': Series_Spain,
'United Kingdom': Series_UnitedKingdom,
'US': Series_US}
selected_data_raw = pd.DataFrame(frame)
selected_data = selected_data_raw[4:].reset_index()
selected_data = selected_data.rename(columns={'index': 'Date'})
# display(selected_data)
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment