About 3,340,000 results
Open links in new tab
  1. Pandas make new column from string slice of another column

    Adding a solution for when you want to take the second element from your pandas dataframe index, which is a tuple, and move it into its own column. Not sure if there is a shorter way to do …

  2. Creating a New Column in Pandas from String Slices – …

    Dec 23, 2024 · In this article, we will explore how to accomplish this using Pandas. Before diving into creating a new column from string slices, let’s briefly understand the concept of string …

  3. Python | Creating a Pandas dataframe column based on a …

    Oct 30, 2025 · In data analysis, it is often necessary to add a new column to a DataFrame based on specific conditions. This article demonstrates multiple methods to create a column in …

  4. Pandas: Make new Column from string Slice of another Column

    Apr 12, 2024 · A step-by-step illustrated guide on how to add a new column from a string slice of another column in multiple ways.

  5. Construct a DataFrame in Pandas using String Data

    Sep 29, 2025 · Using a dictionary of strings Pandas easily converts this dictionary into a DataFrame. Each key represents a column name and values are stored as lists of strings. …

  6. Create new column if DataFrame contains specific string

    Jan 8, 2020 · I have one column in the DataFrame that is a name. Inside this name there are patterns that I want to locate, and create a category in other column of same DataFrame.

  7. Pandas: Updating Column B value if A contains string

    Oct 20, 2021 · I'm looking to create/update a new column, 'dept' if the text in column A contains a string. It's working without a forloop involved but when I try to iterate it is setting the default …

  8. str.contains to create new column in pandas dataframe

    Rather than use a loop or apply you can use the vectorised str.contains to return a boolean mask and set all rows where the condition is met to your desired value:

  9. Add a new column with condition if a string 'contains' substring?

    Aug 22, 2022 · I want to add a new column 'check' with the following condition: 'Suppression total' and 'Sup-SDM'. OR Suppression partiel and Franc SUP - Geisi Dataframe: Type Info Sup_EF …

  10. python - Create New Column Based On String - Stack Overflow

    Jan 10, 2019 · I want to look for certain strings ("ball" or "box") and create a new column based on whether the column contains that word. If the dataframe doesn't contain that word, add "other".