Selecting and importing only certain columns from

2020-02-11 08:59发布

问题:

'I have an excel file which contains many columns with strings, but i want to import certain columns of this excel file containing 'NGUYEN'.

I want to generate a string from columns in my excel which had 'NGUYEN' in them.

import pandas as pd
data = pd.read_excel("my_excel.xlsx", parse_cols='NGUYEN' in col for cols in my_excel.xlsx, skiprows=[0])
data = data.to_string()
print(data)


SyntaxError: invalid syntax

my_excel.xlsx

Function output should be

data =  'NGUYEN VIETNAM HANOIR HAIR PANTS BIKES CYCLING ORANGE GIRL TABLE DARLYN NGUYEN OMG LOL'