Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get certain columns pandas with 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)
Comment

PREVIOUS NEXT
Code Example
Python :: get all values of a dict python 
Python :: convert torch to numpy 
Python :: all possible combinations of parameters 
Python :: sort by dataframe 
Python :: change value to string pandas 
Python :: How to get the current user email from the account logged in? odoo 
Python :: on message discord py 
Python :: convert excel to csv using python 
Python :: delete index in elasticsearch python 
Python :: how to clear a pickle file 
Python :: how to install python 3.6 ubuntu 
Python :: torchviz 
Python :: read text file in python 
Python :: from matrix to array python 
Python :: my pygame window wont stay open 
Python :: python range backward 
Python :: default argument in flask route 
Python :: pyperclip 
Python :: How to get all links from a google search using python 
Python :: reverse string in python 
Python :: pickle.load python 
Python :: django filter text first character upper case 
Python :: round list of floats python 
Python :: get href scrapy xpath 
Python :: how to count non null values in pandas 
Python :: pandas summarize all columns 
Python :: pandas replace values with only whitespace to null 
Python :: select rows which entries equals one of the values pandas 
Python :: pandas shift columns up until value 
Python :: key press python 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =