-
-
Save mprzybyla123/d3a298a8598c2c653c14c87ba20ed236 to your computer and use it in GitHub Desktop.
pandas-append
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All the python code below for use: | |
# import library | |
import pandas as pd | |
# read in your dataframe | |
df = pd.read_csv('/Users/data.csv') | |
# print out your first five rows | |
df.head() | |
# write out new rows | |
rows = [pd.Series([200, 200, 30,'Yellow','Label_1'], index=df.columns), | |
pd.Series([200, 120, 40,'Red','Label_2'], index=df.columns), | |
pd.Series([120, 40, 200,'Red','Label_3'], index=df.columns)] | |
# append the multiple rows | |
new_df = df.append(rows, ignore_index=True) | |
# check the newest 3 rows you made | |
new_df.tail(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment