how to create new dataframe from existing dataframe pandas code example
Example 1: python create new pandas dataframe with specific columns
new_dataframe = old_dataframe.filter(['Columns','you','want'], axis=1)
Example 2: create dataframe with column names pandas
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: []
Example 3: create new dataframe from existing data frame python
new = old.filter(['A','B','D'], axis=1)
Example 4: copy only some columns to new dataframe in r
new = old[['A', 'C', 'D']].copy()
Example 5: copy only some columns to new dataframe in r
new = pd.DataFrame([old.A, old.B, old.C]).transpose()
Example 6: create new dataframe from existing dataframe pandas
new = old[['A', 'C', 'D']].copy()