Python Создайте новые DataFrame Pandas с конкретными столбцами
# Basic syntax:
new_dataframe = old_dataframe.filter(['Columns','you','want'], axis=1)
Charles-Alexandre Roy
# Basic syntax:
new_dataframe = old_dataframe.filter(['Columns','you','want'], axis=1)
In [4]: import pandas as pd
In [5]: df = pd.DataFrame(columns=['A','B','C','D','E','F','G'])
In [6]: df
Out[6]:
Empty DataFrame
Columns: [A, B, C, D, E, F, G]
Index: []
new = old[['A', 'C', 'D']].copy()
new = old[['A', 'C', 'D']].copy()
new = old.filter(['A','B','D'], axis=1)
new = old.filter(['A','B','D'], axis=1)