I have a DataFrame wich has 2 'columns'. The first column does not seem to have a column name, the second one is named Speed
.
Here is a MRE:
from io import StringIO # to read strings as files for read_csv
import pandas as pd
parts = [
'[Level1]\nLocation = "London"\nType= "GTHY66"\n'
'Date = "16-11-2021"\nEnergy level = "Critical zero"\n',
'0.000 26.788\n0.027 26.807\n0.053 26.860'
]
lvl2_lines = "Speed\n" + parts[1]
df_level2 = pd.read_csv(StringIO(lvl2_lines), sep='\t')
print(df_level2.columns)
print(df_level2)
This was my output when I did the print statements:
Index(['Speed'], dtype='object')
Speed
0 0.000 26.788
1 0.027 26.807
2 0.053 26.860
This is my desired output:
Index(['Power', 'Speed'], dtype='object')
Power Speed
0 0.000 26.788
1 0.027 26.807
2 0.053 26.860