Python Forum
Add a row to a dataframe or append whole dataframe.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add a row to a dataframe or append whole dataframe.
I found the solution myself, I don't know if this is clean, proper but it works.
Never touch a working script...
I am sure this will help others.

import pandas as pd
import glob
path = r"path\to\my\folder\*.csv"
df2 = pd.DataFrame(columns=['Name','Reading', 'Office','Phone','address' ])

csvfiles = []
for file in glob.glob(path):
   # print(file)

for csvnub in csvfiles:
   count_row = df.shape[0]
   df2=pd.concat([df, df2])

df2.drop_duplicates(keep='first', inplace=True)
df2.to_csv("InfosTotal.csv", index=True, encoding="utf_8_sig")

Messages In This Thread
RE: Add a row to a dataframe or append whole dataframe. - by tsurubaso - Jan-07-2021, 01:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas dictionary dataframe help michaelserra 4 161 Jun-19-2021, 10:26 AM
Last Post: michaelserra
  AttributeError: 'DataFrame' object has no attribute 'Articles' Anldra12 5 252 Jun-17-2021, 04:54 PM
Last Post: Larz60+
  [solved] dataframe and read_csv ju21878436312 4 288 Jun-16-2021, 06:01 AM
Last Post: ju21878436312
  How to rename dataframe columns based on the content in an index? ar_mahdavi 2 439 Jun-07-2021, 06:09 AM
Last Post: ricslato
  Reading data to python: turn into list or dataframe hhchenfx 2 177 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 240 May-04-2021, 10:51 PM
Last Post: rhat398
  How to get value in Dataframe given row & column values? moonlight 1 265 Apr-26-2021, 09:30 PM
Last Post: Larz60+
  dataframe cell conditional format by row SriRajesh 0 362 Apr-24-2021, 11:51 AM
Last Post: SriRajesh
Star Split and organize my Pandas Dataframe brunolelli 4 410 Apr-18-2021, 03:00 AM
Last Post: brunolelli
  How to save json data in a dataframe shantanu97 1 332 Apr-15-2021, 02:44 PM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020