Introduction to Pandas in Python

Introduction to Pandas in Python
1 / 18
next
Slide 1: Slide

This lesson contains 18 slides, with interactive quizzes and text slides.

Items in this lesson

Introduction to Pandas in Python

Slide 1 - Slide

This item has no instructions

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

Slide 2 - Slide

This item has no instructions

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

Slide 3 - Mind map

This item has no 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 - Slide

This item has no 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 - Slide

This item has no 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 - Slide

This item has no 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 - Slide

This item has no instructions

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





Output:
7

Slide 8 - Slide

This item has no 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 - Slide

This item has no 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 - Slide

This item has no 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 - Slide

This item has no 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 - Slide

This item has no instructions

Basic Data Operations with Pandas
Performing basic data analysis operations

Slide 13 - Slide

This item has no instructions

Lesson Summary
Recap of the main topics and learning objectives

Slide 14 - Slide

This item has no 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 - Slide

This item has no instructions

Write down 3 things you learned in this lesson.

Slide 16 - Open question

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 question

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 question

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.