dataframe only some columns code example
Example 1: how to keep only certain columns in dataframe
df.drop(df.columns[[1, 2]], axis=1, inplace=True)
df1 = df1.drop(['B', 'C'], axis=1)
df1 = df[['a','d']]
Example 2: how to pick out separate columns from the pandas dataframe object
df1 = df.iloc[:, 0:2]
df1 = df[['a', 'b']]
Example 3: python: select specific columns in a data frame
df = df[["Column_Name1", "Column_Name2"]]
Example 4: how to get only certain columns in pandas
print(df[['column_name_1', 'column_name_2', ... , 'column_name_n']])