Uploaded May 2020 | Updated November 2026, 2 hours ago
This video covers the basic math operators built into Python and the math library, including the modulo operation and rounding functions.
This is lesson 2 of a 30-part introduction to the Python programming language for data analysis and predictive modeling. Link to the code notebook below:
Python for Data Analysis: Python Arithmetic
kaggle.com/hamelg/python-for-data-2-python-arithmetic
This guide does not assume any prior exposure to Python, programming or data science. It is intended for beginners with an interest in data science and those who might know other programming languages and would like to learn Python.
I will create the videos for this guide such that you should be able to learn a lot just watching on YouTube, but to get the most out of the guide, it is recommended that you create a Kaggle account so that you can copy and edit each lesson so that you can follow along and run code yourself.
In Part 1 of this series, we discussed the basics of what Python is and how we will interact with Python using the Kaggle Jupyter notebook environment. With those preliminaries out of the way, we can jump in and start learning Python. In this short lesson, we'll learn how to use Python to do arithmetic operations.
Python allows you to perform all of the basic mathematical computations that you can perform on a calculator, using syntax similar to what you'd expect if you were using a calculator. To perform arithmetic with Python, simply type the operation you wish to perform into a code cell and then run the cell to view the result. (Remember, if you like you can copy and edit this notebook using the blue button at the top of the screen and then run code cells yourself by selecting the cell you wish to run and pressing control + enter.).
Introduction to Python Playlist:
youtube.com/playlist?list=PLiC1doDIe9rCYWmH9wIEYEXXaJ4KAi3jc
Link to the Python for Data Analysis written guide page:
kaggle.com/hamelg/python-for-data-analysis-index .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only
This video covers the basic math operators built into Python and the math library, including the modulo operation and rounding functions.
This is lesson 2 of a 30-part introduction to the Python programming language for data analysis and predictive modeling. Link to the code notebook below:
Python for Data Analysis: Python Arithmetic
kaggle.com/hamelg/python-for-data-2-python-arithmetic
This guide does not assume any prior exposure to Python, programming or data science. It is intended for beginners with an interest in data science and those who might know other programming languages and would like to learn Python.
I will create the videos for this guide such that you should be able to learn a lot just watching on YouTube, but to get the most out of the guide, it is recommended that you create a Kaggle account so that you can copy and edit each lesson so that you can follow along and run code yourself.
In Part 1 of this series, we discussed the basics of what Python is and how we will interact with Python using the Kaggle Jupyter notebook environment. With those preliminaries out of the way, we can jump in and start learning Python. In this short lesson, we'll learn how to use Python to do arithmetic operations.
Python allows you to perform all of the basic mathematical computations that you can perform on a calculator, using syntax similar to what you'd expect if you were using a calculator. To perform arithmetic with Python, simply type the operation you wish to perform into a code cell and then run the cell to view the result. (Remember, if you like you can copy and edit this notebook using the blue button at the top of the screen and then run code cells yourself by selecting the cell you wish to run and pressing control + enter.).
Introduction to Python Playlist:
youtube.com/playlist?list=PLiC1doDIe9rCYWmH9wIEYEXXaJ4KAi3jc
Link to the Python for Data Analysis written guide page:
kaggle.com/hamelg/python-for-data-analysis-index .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only


![How To Use zip() in Python
zip() is a Python built in that lets you combine two or more iterable objects like lists into groups of tuples. zip() is a convenient way of grouping data in multiple lists together in an elementwise fashion.
*Note: Longitude is misspelled in the video! I corrected this in the code below.*
Code used in the video:
# Use zip() to combine iterables like lists into tuples (elementwise)
# Useful for making separate lists into tuples
latitude = [4,5,6,4,6,2,4,5,6]
longitude = [6,3,6,3,4,5,6,8,5]
[*zip(latitude, longitude)]
# Can operate on more than 2 inputs
altitude = [12,41,15,16,15,23,14,51,61]
[*zip(latitude, longitude, altitude)]
# Zip will only continue up to the length of the shortest input
short = [1,2,3,4]
long = [1,2,3,4,5,6,7,8]
[*zip(short, long)]
# If you want to keep all items, use itertools.zip_longest
from itertools import zip_longest
short = [1,2,3,4]
long = [1,2,3,4,5,6,7,8]
[*zip_longest(short, long, fillvalue=None)]
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. How To Use zip() in Python](https://i.ytimg.com/vi/kG6nhCinNus/mqdefault.jpg)

![How to Access Columns by Numeric Index in Pandas (Python)
↓ Code Available Below! ↓
This video shows how to access the columns of a pandas data frame using the numeric index using iloc. Using numeric indexes to get columns can make it easier to select multiple columns or large ranges of columns since you dont have to know or type out all of the column names.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset(mtcars, datasets, cache=True).data
mtcars.head()
# Access a column by numerical index
mtcars.iloc[:, 2]
# Access multiple column by numerical index
mtcars.iloc[:, [2,4,5]]
# Access multiple columns and a subset of rows
mtcars.iloc[[1,5,7], [2,4,5]]
# Access columns with a column subset
mtcars[mtcars.columns[[2,4,5]]]
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only How to Access Columns by Numeric Index in Pandas (Python)](https://i.ytimg.com/vi/lJvG1FpghA4/mqdefault.jpg)
![How to Access Rows by Numeric Index in Pandas (Python)
↓ Code Available Below! ↓
This video shows how to access the rows of a pandas data frame using the numeric index of the row using iloc. Using numeric indexes to get rows can be more natural than using the row index names because base Python data structures like lists dont have index names.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset(mtcars, datasets, cache=True).data
mtcars.head()
# Access a row by numerical index with .iloc
mtcars.iloc[2]
# Access multiple rows by numerical index
mtcars.iloc[[2,4,5]]
# Access multiple rows and specific columns (by numeric index)
mtcars.iloc[[2,4,5], [0, 1, 3]]
# Access multiple rows and specific columns (by col name)
mtcars.iloc[[2,4,5]][[mpg, cyl]]
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only How to Access Rows by Numeric Index in Pandas (Python)](https://i.ytimg.com/vi/lLhcFkPwaqs/mqdefault.jpg)




