📌  相关文章
📜  使用字符串获取某些列 pandas - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:17.285000             🧑  作者: Mango

代码示例1
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)