How to know (and display) all columns of a dataframe in Python
Prerequisites
We will once again use the (famous) pandas library used in Python.
For installation, you have the solutions below:
for Python
pip install pandas
for Python 3
pip3 install pandas
You will only need to install your library once -- Unless you are on different environments/machines
And then you will need to load the library – each time/each script launch – and to do this:
import pandas as pd
Display columns using pandas in Python
To display the columns of a dataframe in Python, you have two solutions:
Solution 1
for col in df.columns: print(col)
Solution 2
print(df.columns)
For each column (col) of the dataframe df (in df.columns) and then display (print) the result using print()