Commit 39943e88 authored by François Bouchet's avatar François Bouchet
Browse files

Mise à jour 2021

parents ace85ee8 c274ec0e
1. Allez sur https://www.kaggle.com/learn/pandas
et faites les tutoriels suivants:
1.1. Creating, Reading and writing
1.2. Indexing, selecting and assigning
2. Puis allez ici:
https://campus.datacamp.com/courses/intermediate-python-for-data-science/matplotlib?ex=1
Faites l'exercice pour apprendre à tracer des graphiques avec le module matplotlib.
Vous pouvez regarder la vidéo avec les sous-titres, ou passer la vidéo, et aller directement à l'exercice.
L'exercice rééxplique tout ce qui est utile.
%% Cell type:markdown id: tags:
**[Pandas Home Page](https://www.kaggle.com/learn/pandas)**
---
%% Cell type:markdown id: tags:
# Introduction
The first step in most data analytics projects is reading the data file. In this exercise, you'll create Series and DataFrame objects, both by hand and by reading data files.
Run the code cell below to load libraries you will need (including code to check your answers).
%% Cell type:code id: tags:
``` python
import pandas as pd
#pd.set_option('max_rows', 5)
print("Setup complete.")
```
%% Cell type:markdown id: tags:
# Exercises
%% Cell type:markdown id: tags:
## 1.
In the cell below, create a DataFrame `fruits` that looks like this:
![](https://i.imgur.com/Ax3pp2A.png)
%% Cell type:code id: tags:
``` python
# Your code goes here. Create a dataframe matching the above diagram and assign it to the variable fruits.
fruits = ____
# Check your answer
fruits
```
%% Cell type:markdown id: tags:
## 2.
Create a dataframe `fruit_sales` that matches the diagram below:
![](https://i.imgur.com/CHPn7ZF.png)
%% Cell type:code id: tags:
``` python
# Your code goes here. Create a dataframe matching the above diagram and assign it to the variable fruit_sales.
fruit_sales = ____
# Check your answer
fruit_sales
```
%% Cell type:markdown id: tags:
## 3.
Create a variable `ingredients` with a Series that looks like:
```
Flour 4 cups
Milk 1 cup
Eggs 2 large
Spam 1 can
Name: Dinner, dtype: object
```
%% Cell type:code id: tags:
``` python
ingredients = ____
# Check your answer
ingredients
```
%% Cell type:markdown id: tags:
## 4.
Download this file : https://gitlab.lip6.fr/bouchet/damivis/blob/master/data/Exam2017.csv
Open it.
What is the file path to access it on your computer?
%% Cell type:code id: tags:
``` python
filepath=____
```
%% Cell type:markdown id: tags:
Read it:
%% Cell type:code id: tags:
``` python
examResults = ____
# Check your answer
examResults
```
%% Cell type:markdown id: tags:
## 5.
Run the cell below to create and display a DataFrame called `animals`:
%% Cell type:code id: tags:
``` python
animals = pd.DataFrame({'Cows': [12, 20], 'Goats': [22, 19]}, index=['Year 1', 'Year 2'])
animals
```
%% Cell type:markdown id: tags:
In the cell below, write code to save this DataFrame to disk as a csv file with the name `cows_and_goats.csv`.
%% Cell type:code id: tags:
``` python
# Your code goes here
```
%% Cell type:markdown id: tags:
Find the file you created. Open it is it correct?
%% Cell type:markdown id: tags:
# Keep going
Move on to learn about **[indexing, selecting and assigning](https://www.kaggle.com/residentmario/indexing-selecting-assigning)**.
%% Cell type:markdown id: tags:
---
**[Pandas Home Page](https://www.kaggle.com/learn/pandas)**
*Have questions or comments? Visit the [Learn Discussion forum](https://www.kaggle.com/learn-forum) to chat with other Learners.*