Search code examples
pythonpandasdata-science

Pandas column separation using .loc


I am an amateur user. I watched many videos but I couldn't figure out this error.

Code

How can I keep PERSON_WGHT, LOS, and IDC_DC_CD_1 as a columns for all rows that is 386816.


Solution

  • If you need to select multip0le columns from all the records then use df[[column_list]].

    df_new = df[['PERSON_WGHT', 'LOS', 'IDC_DC_CD_1']]