Hackerss.com

hackerss
hackerss

Posted on • Updated on

Python Copy a dataframe to a new one


#import pandas as pd
import pandas as pd

#create a dataframe
df = pd.DataFrame({'A':[1,2,3,4], 'B':[5,6,7,8]})

#copy the dataframe
df_copy = df.copy()

#print the dataframe
print(df_copy)

#output
#   A  B
#0  1  5
#1  2  6
#2  3  7
#3  4  8
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)