
Pandas get column names
Pandas get column names : When analyzing large datasets, it may be necessary to obtain column names to perform certain operations on the dataset. In this article, I will show you four ways to retrieve column names in a Pandas dataframe. Let’s start by creating a relatively simple dataset. # Import pandas package import pandas as pd # Import dataset from csv df=pd.read_csv("http://samplecsvs.s3.amazonaws.com/SacramentocrimeJanuary2006.csv") # Displays the first lines df_head = data.head() df_head Now let’s try to get the names of the columns in the above data set. 1st method: Iterate on the names of the column : # iterating the columns for col in…