I was looking for an answer to the same problem which is why I found your question.
I know this response is 25 days late but It's my first response on StackOverflow (or any site for that matter) so I'm doing it anyway.
Also, maybe somebody else needs an answer to this in the future. I hope this helps.
I'm a newbie so I'm happy to receive pointers/criticism (no matter how big or small) on how I responded.
In order to recreate your df mockup, I had to fix some parentheses in your code and
get rid of 'self' as part of the variable b/c it generated an error for me.
Also, I added the sort_index() to reverse the index as you have it.
import numpy as np
import pandas as pd
column = [_ for _ in 'ABCDEFGH']
row = range(12, 0, -1)
# board = np.full((12, 8), 7) # to test dtype changes
board = np.full((12, 8), '||')
df0 = pd.DataFrame(board, index=row,
columns=column).sort_index(ascending=False)
Manually create dict where keys = column.values and values = strings of the same names.
footer = {'A':'A', 'B':'B', 'C':'C', 'D':'D', 'E':'E', 'F':'F', 'G':'G', 'H':'H'}
Or make python do it for you
keys = list(df0.columns.values)
values = list(df0.columns.values)
footer = dict(zip(keys, values))
Append df0 with the dict.
df1 = df0.append(footer, ignore_index=True)
Got footer but didn't reverse index.
An error "Can only append a Series if ignore_index=True or if the Series has a name", which is why the index isn't reversed.
So this could work for others who don't have that need to reverse the index.
It's what I needed for displaying Headers and Footers for baseball stats.
df2 = df0.append(pd.Series((pd.Series(footer)), name='Footer')) # Change 'Footer' to any text
Had to put the footer into nested pd.Series() and add a name to remedy the above error.
Without the nesting you get this error: "append() got an unexpected keyword argument 'name'"
df3 = df0.append(pd.Series((pd.Series(footer)), name='')) # Same as df2 but blank name
df0 matches your mockup dataframe.
df1 is the solution with untitled footer but ascending index.
df2 is the solution with titled footer and correct index.
df3 is the solution with untitled footer and correct index.
All of the above have both Headers and Footers, and OP wanted just footers. So, I found this below to finish the task:
Pandas - delete column name
@jezrael gave this succinct line to get rid of the headers (but with safety caveats - might be best to keep both headers and footers.)
df4 = df3
df4.columns = [''] * len(df4.columns)
print(df4) # OP's solution
Appending a series of strings to existing DF columns will convert all dtypes to objects.
I think the workaround here if you need to calc over columns, would be to calc over the columns of df0 instead of
those of df4, store them where you want, then get them into df4 to display df4 with the new data.
I hope that helps.