Uploaded October 2020 | Updated November 2026, 2 hours ago
↓ Code Available Below! ↓
This video shows how to match all whitespace characters using the regular expressions package in Python. Text data often contains words split by whitespace that you might have an interest in extracting, but whitespace separators are not limited to single spaces. You might encounter multiple spaces in a row, tab characters and newlines as well. Python regular expressions make it easy to match and split words on all whitespace.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import re
lines = '''Nappa - What does the scouter say about his power level?
Vegeta - It's over 9000!
Nappa - What 9000? That can't be right. \t Can it?'''
re.split(pattern = " ",
string = lines)
# Use \s to match white space:
re.split(pattern = "\s+",
string = lines)
# Use \S to match everything other than whitespace:
re.findall(pattern = "\S+",
string = lines)
* 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: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only
↓ Code Available Below! ↓
This video shows how to match all whitespace characters using the regular expressions package in Python. Text data often contains words split by whitespace that you might have an interest in extracting, but whitespace separators are not limited to single spaces. You might encounter multiple spaces in a row, tab characters and newlines as well. Python regular expressions make it easy to match and split words on all whitespace.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import re
lines = '''Nappa - What does the scouter say about his power level?
Vegeta - It's over 9000!
Nappa - What 9000? That can't be right. \t Can it?'''
re.split(pattern = " ",
string = lines)
# Use \s to match white space:
re.split(pattern = "\s+",
string = lines)
# Use \S to match everything other than whitespace:
re.findall(pattern = "\S+",
string = lines)
* 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: 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)





