Articles → Pandas → Index And Columns Attribute In Dataframe In Pandas
Index And Columns Attribute In Dataframe In Pandas
Index
import pandas as pd
list = [[1, 21, 3], [4, 5, 6], [7, 8, 9]]
df = pd.DataFrame(list, columns=["col1", "col2", "col3"])
print(df.index)
Click to Enlarge
Columns
import pandas as pd
list = [[1, 21, 3], [4, 5, 6], [7, 8, 9]]
df = pd.DataFrame(list, columns=["col1", "col2", "col3"])
print(df.columns)
Click to Enlarge