Answers for "python - find specific name in a df"

1

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)
Posted by: Guest on January-09-2020
2

get columns containing string

df2 = df.filter(regex='spike')
print(df2)
Posted by: Guest on January-08-2020
0

python - find specific name in a df

i = df[df['Name']=='Will']
print(i)
Posted by: Guest on November-06-2020

Code answers related to "python - find specific name in a df"

Python Answers by Framework

Browse Popular Code Answers by Language