Skip to content

Instantly share code, notes, and snippets.

@SolClover
Last active August 8, 2020 03:46
Show Gist options
  • Save SolClover/aa9ef0fe89542b2be29b2c1496fe0f64 to your computer and use it in GitHub Desktop.
Save SolClover/aa9ef0fe89542b2be29b2c1496fe0f64 to your computer and use it in GitHub Desktop.
Copy Pandas DataFrame
# Create new DataFrame based on old DataFrame
# Note, in this example you will create a view.
# Hence, your future changes to new_df will affect old_df too
new_df=old_df
# To make an actual copy of a DataFrame use this.
# In this case, future changes to new_df will not have an impact on old_df
new_df=old_df.copy()
# Print top 5 records of your new DataFrame
new_df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment