Data Manipulation with Pandas
Pandas is built on NumPy and Matplotlib
Exploring a DataFrame
Data Manipulation with Pandas 1
Sorting
Data Manipulation with Pandas 2
Subsetting
Adding a new column
Summary statistics
Data Manipulation with Pandas 3
.agg( ) allows you to compute
summary statistics
The .agg() method allows you to
apply your own custom functions
to a DataFrame, as well as apply
functions to more than one column
of a DataFrame at once, making
your aggregations super-efficient.
Counting
Data Manipulation with Pandas 4
Grouped Summary Statistics
Data Manipulation with Pandas 5
Pivot tables
Pivot tables are the standard way of aggregating data in spreadsheets. In pandas,
pivot tables are essentially just another way of performing grouped calculations.
That is, the .pivot_table() method is just an alternative to .groupby().
Data Manipulation with Pandas 6
Contain the mean of all the values in the column or row, not including the missing
values that we're filled in with 0s.
Marin=true will give you a summary statistics of your dataset.
Explicit indexes
Original dataset:
Data Manipulation with Pandas 7
Explicit index functions:
Data Manipulation with Pandas 8
Slicing and subsetting with .loc and .iloc
Data Manipulation with Pandas 9
Data Manipulation with Pandas 10
Working with Pivot tables
Data Manipulation with Pandas 11
Creating and Visualizing DataFrames
Visualizing your data
Data Manipulation with Pandas 12
Data Manipulation with Pandas 13
Missing values
In a pandas DataFrame, missing values are indicated with N-a-N, which stands for "not
a number."
When you first get a DataFrame, it's a good idea to get a sense of whether it contains
any missing values, and if so, how many. That's where the isna method comes in. When
we call isna on a DataFrame, we get a Boolean for every single value indicating
whether the value is missing or not, but this isn't very helpful when you're working with a
lot of data.
Data Manipulation with Pandas 14
Data Manipulation with Pandas 15
Data Manipulation with Pandas 16
Creating DataFrames
Data Manipulation with Pandas 17
Reading and writing CSVs
Data Manipulation with Pandas 18
Data Manipulation with Pandas 19