Skip to content
Advertisement

Trying to pass user input in usecols Pandas

I’m trying to ask the user which columns do they want read in the dataframe from a csv file. I’ve been trying the following:

JavaScript

But even this gives an error. Any suggestions? I think so I’m not able to understand the lambda function. The error I’m getting is: pandas.errors.EmptyDataError: No columns to parse from file

Advertisement

Answer

You can pass the col list as the answer to the usecols parameter.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement