Given a 3x3 dataframe, with index and column names to be included as a row/column themselves when converting the dataframe to a CSV file, how can I shift the table down 1 row?
I want to shift down 1 row, leaving 1 empty row to write to the CSV after using a completely separate list.
The code and comments below include more detail and clarity regarding my goal:
import pandas as pd
separate_row = [' ', 'Z', 'Y', 'X']
# Note: The size is 3x3
x = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
header_cols = ['a','b','c']
df = pd.DataFrame(x, index=[1,2,3], columns=header_cols)
# Note: Exporting as 4x4 now
df.to_csv('data.csv', index=True, header=True)
# How to make CSV file 5x4??
Row 1 in the CSV file will be filled by separate_row, though I cannot have separate_row as the column name when creating the dataframe. The column name MUST be header_cols but separate_row is to go above.