Introduction to Pandas in Python

Introduction to Pandas in Python
1 / 18
suivant
Slide 1: Diapositive

Cette leçon contient 18 diapositives, avec quiz interactifs et diapositives de texte.

Éléments de cette leçon

Introduction to Pandas in Python

Slide 1 - Diapositive

Cet élément n'a pas d'instructions

Learning Objectives
At the end of the lesson you will understand the purpose and functionality of the Pandas library in Python.

Slide 2 - Diapositive

Cet élément n'a pas d'instructions

What do you already know about the Pandas library in Python?

Slide 3 - Carte mentale

Cet élément n'a pas d'instructions

Overview and Purpose of the Pandas Library
Pandas is a Python library for data manipulation and analysis. 
Pandas library has functions for cleaning, exploring, and manipulating datasets. It has tools for calculating statistical correlations, average, maximum, and minimum values within data.

Slide 4 - Diapositive

Cet élément n'a pas d'instructions

Importing Pandas and Basic Syntax
To use Pandas library, you have to import it in your code.   
import pandas

You can import with the alias 'pd' to simplify the syntax.




Slide 5 - Diapositive

Cet élément n'a pas d'instructions

Understanding and Creating Pandas Series
Series - are one-dimensional arrays with index labels.
A Series is like a column in a table.  
import pandas as pd
a = [1, 7, 2]
myvar = pd.Series(a)
print(myvar)




Output:
0       1
1        7
2       2
dtype: int64

Slide 6 - Diapositive

Cet élément n'a pas d'instructions

Labels in Series
If nothing else is specified, the values are labeled with their index number. First value has index 0, second value has index 1 etc.
Labels can be used to access a specified value.

Slide 7 - Diapositive

Cet élément n'a pas d'instructions

Labels in Series
import pandas as pd
a = [1, 7, 2]
myvar = pd.Series(a)
print(myvar[1])





Output:
7

Slide 8 - Diapositive

Cet élément n'a pas d'instructions

Create Labels in Series
With the index argument, you can name your own labels. When you have created labels, you can access  an item by referring to the label.
import pandas as pd
a = [1, 7, 2]
myvar = pd.Series(a, index = ["x", "y", "z"])
print(myvar)  print(myvar["y"])


Output:
x    1
y    7
z    2
dtype: int64
7

Slide 9 - Diapositive

Cet élément n'a pas d'instructions

Key/Value Objects as Series
You can also use a key/value object, like a dictionary, when creating a Series.
import pandas as pd
calories = {"day1": 420, "day2": 380, "day3": 390}
myvar = pd.Series(calories)
print(myvar)





Output:
day1     420
day2     380
day3     390
dtype: int64

Slide 10 - Diapositive

Cet élément n'a pas d'instructions

Working with DataFrames in Pandas
DataFrames - two-dimensional tables with rows and columns
import pandas as pd
mydataset = {
  'cars': ["BMW", "Volvo", "Ford"],
  'passings': [3, 7, 2]
}  myvar = pd.DataFrame(mydataset)
print(myvar)

Output
    cars passing
0 BMW 3
1   Volvo 7
2   Ford 2

Slide 11 - Diapositive

Cet élément n'a pas d'instructions

Reading Data from Files into Pandas DataFrames
Pandas can read data from files, such as CSV and JSON, and load them into DataFrame objects for analysis

Slide 12 - Diapositive

Cet élément n'a pas d'instructions

Basic Data Operations with Pandas
Performing basic data analysis operations

Slide 13 - Diapositive

Cet élément n'a pas d'instructions

Lesson Summary
Recap of the main topics and learning objectives

Slide 14 - Diapositive

Cet élément n'a pas d'instructions

Definition List
Pandas: A Python library used for data analysis, which provides functions for cleaning, exploring, and manipulating data.
Series: A one-dimensional array in Pandas that can hold data of any type, with index labels.
DataFrame: A two-dimensional data structure in Pandas, similar to a table, with rows and columns for organizing data.
loc: An attribute used in Pandas to access rows in a DataFrame by label or a boolean array.
CSV files: Plain text files that use a comma to separate values, which can be read and manipulated using Pandas.
JSON: A text format for data exchange, resembling Python dictionaries, which can be read into Pandas DataFrames.

Slide 15 - Diapositive

Cet élément n'a pas d'instructions

Write down 3 things you learned in this lesson.

Slide 16 - Question ouverte

Have students enter three things they learned in this lesson. With this they can indicate their own learning efficiency of this lesson.
Write down 2 things you want to know more about.

Slide 17 - Question ouverte

Here, students enter two things they would like to know more about. This not only increases involvement, but also gives them more ownership.
Ask 1 question about something you haven't quite understood yet.

Slide 18 - Question ouverte

The students indicate here (in question form) with which part of the material they still have difficulty. For the teacher, this not only provides insight into the extent to which the students understand/master the material, but also a good starting point for the next lesson.