Answers for "dataframe get only some columns"

3

python - subset specific columns name in a dataframe

columns = ['b', 'c']
df1 = pd.DataFrame(df, columns=columns)
Posted by: Guest on October-20-2020
1

how to pick out separate columns from the pandas dataframe object

df1 = df.iloc[:, 0:2] # If you want to do it by index. Remember that Python does not slice inclusive of the ending index.
df1 = df[['a', 'b']] ## if you want to do it b nae
Posted by: Guest on October-21-2020
0

select only object columns pandas

df.select_dtypes(include=['object']).columns
Posted by: Guest on June-08-2021
0

how to get only one column from dataset in python

df['name']
Posted by: Guest on August-20-2020
0

how to get only certain columns in pandas

#only the column names specified will be put into the new sub df
#enter a minimum of one column name
print(df[['column_name_1', 'column_name_2', ... , 'column_name_n']])
Posted by: Guest on March-15-2021

Code answers related to "dataframe get only some columns"

Python Answers by Framework

Browse Popular Code Answers by Language