Home > other >  Python data frame :Write Data to csv on the next cell
Python data frame :Write Data to csv on the next cell

Time:02-17

I want to write values from a Pandas dataframe to the next immediate cell and not in the first row / column in a csv file which looks like:

  |column 1| Column2| Column 3| 
  |--------|--------|---------|
  |        |        |         |
  |        |data    | data    |
  |        |data    |data     |

I tried , pandasdf.iloc[1,1]= pandasdf

But the existing values are getting replaced , is there a way to do this ? Is it possible to create a sql table in this manner ?

CodePudding user response:

You want to add a single empty row to the top of your existing df. Do this by concating your existing dataframe with a None dataframe, putting the None fame first

pd.concat([pd.DataFrame([None]), df])

This creates a new dataframe, where the first row consists only of None/NaN

  • Related