Uploaded November 2019 | Updated November 2026, 1 hour ago
Character string data manipulation is among the most common data cleaning tasks. Combining two or more strings into one, also known as string concatenation is one of the most basic character data manipulations that you're likely to encounter. It is also useful to know how to perform the reverse operation, splitting an existing string into two or more parts.
Code used in this clip:
string1 <- "Combine"
string2 <- "Me"
string3 <- "Split"
# Concatenate strings
paste(string1, string2)
# Combine with a specified separator
combined <- paste(string3, string2, sep = "--")
combined
# Split the combined string
strsplit(combined, split="--")
# Elementwise concatenation
vector1 <- c("Luke", "Han", "Lando")
vector2 <- c("Skywalker", "Solo", "Calrissian")
combined_vector <- paste(vector1, vector2)
combined_vector
# Elementwise splitting
strsplit(combined_vector, split=" ")
# Concatenate vector elements together into a single string
paste(vector1, collapse = "--")
Code Clips are basic code explanations in 3 minutes or less. They are intended to be short reference guides that provide quick breakdowns and copy/paste access to code needed to accomplish common data science tasks. Think Stack Overflow with a video explanation.
* 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! For R that means I may use = for assignment and the special Unicode large < and > symbols in place of the standard sized ones for dplyr pipes and comparisons. These special symbols should work as expected for R code on Windows, but may need to be replaced with standard greater than and less than symbols for other operating systems.
Character string data manipulation is among the most common data cleaning tasks. Combining two or more strings into one, also known as string concatenation is one of the most basic character data manipulations that you're likely to encounter. It is also useful to know how to perform the reverse operation, splitting an existing string into two or more parts.
Code used in this clip:
string1 <- "Combine"
string2 <- "Me"
string3 <- "Split"
# Concatenate strings
paste(string1, string2)
# Combine with a specified separator
combined <- paste(string3, string2, sep = "--")
combined
# Split the combined string
strsplit(combined, split="--")
# Elementwise concatenation
vector1 <- c("Luke", "Han", "Lando")
vector2 <- c("Skywalker", "Solo", "Calrissian")
combined_vector <- paste(vector1, vector2)
combined_vector
# Elementwise splitting
strsplit(combined_vector, split=" ")
# Concatenate vector elements together into a single string
paste(vector1, collapse = "--")
Code Clips are basic code explanations in 3 minutes or less. They are intended to be short reference guides that provide quick breakdowns and copy/paste access to code needed to accomplish common data science tasks. Think Stack Overflow with a video explanation.
* 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! For R that means I may use = for assignment and the special Unicode large < and > symbols in place of the standard sized ones for dplyr pipes and comparisons. These special symbols should work as expected for R code on Windows, but may need to be replaced with standard greater than and less than symbols for other operating systems.






![How to Remove a Column From a Data Frame in Pandas (Python)
This video shows 3 ways to remove columns from Data Frames in the Pandas library for Python.
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()
# Delete by column by name
del mtcars[cyl]
mtcars.head()
# Delete columns by name with df.drop()
mtcars = mtcars.drop([hp, carb], # Cols to drop
axis = 1) # 1 for columns
mtcars.head()
# Delete columns by index position with df.drop()
mtcars = mtcars.drop(mtcars.columns[[1,3]], # Index of cols to drop
axis = 1) # 1 for columns
mtcars.head()
* 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 Remove a Column From a Data Frame in Pandas (Python)](https://i.ytimg.com/vi/yRnoP-8zP2I/mqdefault.jpg)


