Skip to content
Advertisement

Call column in dataframe by column index instead of column name – pandas

How can I call column in my code using its index in dataframe instead of its name.

For example I have dataframe df with columns a, b, c

Instead of calling df['a'], can I call it using its column index like df[1]?

Advertisement

Answer

You can use iloc:

JavaScript

Example:

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