Append New Data On Pandas Dataframe Code Example

Snippet 1

  df = df.append({'index1': value1, 'index2':value2,...}, ignore_index=True) 

Snippet 2

  DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=None) 

Snippet 3

   df.loc[-1] = [2, 3, 4]  # adding a row
 df.index = df.index + 1  # shifting index
 df = df.sort_index()  # sorting by index
  
 # And you get:

#    A  B  C
# 0  2  3  4
# 1  5  6  7
# 2  7  8  9 

Copyright © Code Fetcher 2020

 

 

Leave a comment

Your email address will not be published. Required fields are marked *