Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

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

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

Top comments (0)