This is probably pretty basic question, but I am stuck here. I would like to print a empty pandas dataframe on console with headers. I will try to explain it here.
I create a dataframe with a dictionary and print it, it prints the data with headers.
>>> details = {'EmpId' : [1, 2],'EmpName' : ["A", "B"]}
>>> df = pd.DataFrame(details)
>>> print(df)
EmpId EmpName
0 1 A
1 2 B
But if for some reason dataframe is empty, then it just prints Empty DataFrame.
>>> import pandas as pd
>>> df = pd.DataFrame(columns=['Emp Id', 'Emp Name'])
>>> print (df)
Empty DataFrame
Columns: [Emp Id, Emp Name]
Index: []
Question here is - is it possible to display something like below
>>> print(df)
EmpId EmpName