get columns containing string

import pandas as pd

data = {'spike-2': [1,2,3], 'hey spke': [4,5,6], 'spiked-in': [7,8,9], 'no': [10,11,12]}
df = pd.DataFrame(data)

spike_cols = [col for col in df.columns if 'spike' in col]
print(list(df.columns))
print(spike_cols)

4
5
LAMonday 80 points

                                    df2 = df.filter(regex='spike')
print(df2)

4 (5 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
columns that contain a string only string columns pandas select columns with string pandas pandas columns with string in name find a columns with name that contain specific substring how to find columns in pandas that start with specific string select columns that contain string pandas get string columns pandas how to get only string columns in pandas to display columns with a particular string pandas read certain column as string pandas column names which contain string contains column names which contain string contain column names which contain string pandas only columns with a string pandas get string columns get pandas fileds which contrain striung select columns with specific string pandas pandas if column name python pandas print row where column contains find column names dataframe regex word get name of columns jdbc for each row in dataframe search for string in columns how to get a location name from a string in pandas pandas get certain columns get rows that contain this and that get columns containing string if you want to search particular name is particular column in python querying a column with a specific strings in pandas querying a column with a specific string in pandas subset columns pandas by str how to print a certain column in pd dataframe how to get all strings columns in pandas python get row that equals string python dataframe get certain columns python pandas print specific columns pandas find rows with a given string in column pandas dataframe get columns like pandas select columns wich contains match column names pandas dfcolumns.contains python first row of dataframe contains string get list of columns that contain string in pandas pandas print matching column names python select columns with name like find column with contains in namepandas pandas find column by string name select the columns whoch contain particular string in python how to identify columns that contains a substring select column name which has specific string in pandas how to get columns with string match in pandas pandas keep columns containing string selecting columns in pandas that contain a string column name doesnt consist of string python data frame extract columns that contais strin python - find specific name in a df search pandas columns that contain select columns containing string pandas pandas select columns with name like find string in dataframe aliases list pandas select columns if name contains dataframe loc column names containing a string filter dataframe with name contains string find take a column with particular bame in python pandas select columns by name pattern python column name matches pattern get columns matching headr name pandas search for column name in pandas filter by a word in pandas dataframe only rows that contain string that contains filter cells where string dataframe select any column header that contains pandas pandas find similar named columns get column names contains string python regex search for coloumn names pandas how tttoo seelct the columns with string siin pandas check if column name contains string pandas if name is in column python find fina a column contains a particular keyword pandas select string columns pandas pandas dataframe check if column name contains string pandas dataframe check if column name contains if column contains value then get column name python get columns names that contain a certain value python list of columns that have a certain word pandas pandas check if substring appears in column names wildcard pandas use contains for column names on python python pd select columns containing string how to get a dataframe with column that contains a certain string pandas pandas dataframe select columns that contain word x in the name pandas find column names containing string pandas filter out specific text select column pandas name string matching pandas select columns containing string pandas select columns if they contain pandas find all columns containing certain character python select columns if the column names containing select columns pandas with string if column name contains pandas how to find columns with strings in pandas python column name like identify columns which contain address pandas get columns if substring in list get columns if substring in pandas get rows with word like pandas find column contains string python select columm names based on string pandas search string in row pandas use rows that have a string in them filter by column name containes pandas pandas find column that contains string
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source