How to parameterize the column values for df.iloc

I want to get input from a user in order to pass it as a listlike set of integers for iloc, but cannot get the list into a working form like [1,3,4,5] for example.


In the above code, I want to specify column indexes from user input instead of hard coding the numbers in.  Please advise.
Who is Participating?
Marcin KarkochaSenior DevOps Engineer (Nokia)Commented:
Can you precise your question? Is about DataFrames from Pandas or something?
dorianitAuthor Commented:
I want to take input and pass it to the df.iloc column values.  I found a solution wit the code below.  The requirement is that user separate their values with a space, which is okay for me.

chosenfields = [int(x) for x in input("\nPlease choose the fields  (space separated) (example: 0 2 15).  ").split()]
All Courses

From novice to tech pro — start learning today.