Question:I want to add multiple empty rows at start of my dataframe. I have tried using list but it dosen’t seem to return optimum result:
Column names should also start from the nth row, I want to add n empty rows at the beginning of my Dataframe.
Answer:I’m not sure why you would want to do this but I did it by splitting up the original dataframe into a dataframe with a row of the column names and a separate dataframe of the data. I then created a dataframe of nans to be the blank rows and joined the 3 together. You will need to import numpy for this.
I created a variable
no_colsto be the number of columns in the dataframe and
no_empty_rowsto be how many empty rows to simplify code:
dfback together and reset their index, then append that to
If you have better answer, please add a comment about this, thank you!