Introduction to Pandas in Python

Introduction to Pandas in Python
1 / 18
volgende
Slide 1: Tekstslide

In deze les zitten 18 slides, met interactieve quizzen en tekstslides.

Onderdelen in deze les

Introduction to Pandas in Python

Slide 1 - Tekstslide

Deze slide heeft geen instructies

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

Slide 2 - Tekstslide

Deze slide heeft geen instructies

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

Slide 3 - Woordweb

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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





Output:
7

Slide 8 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

Basic Data Operations with Pandas
Performing basic data analysis operations

Slide 13 - Tekstslide

Deze slide heeft geen instructies

Lesson Summary
Recap of the main topics and learning objectives

Slide 14 - Tekstslide

Deze slide heeft geen instructies

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 - Tekstslide

Deze slide heeft geen instructies

Write down 3 things you learned in this lesson.

Slide 16 - Open vraag

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 - Open vraag

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 - Open vraag

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.