My heading names shows up over the wrong column

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



My heading names shows up over the wrong column



How can I flip the positions on hour and count? Please see pic


import pandas as pd

df = pd.read_csv('/Users/lisa/Desktop/data.log', names=[0, 'hour', 2, 3], sep=':', engine='python')

x_df = pd.DataFrame(x)

x_df = x_df.rename_axis('counts')

x_df=(x_df[0: 10])

x_df



enter image description here




1 Answer
1



If I understand you correctly you can use:


x_df.T # or x_df.transpose()



This will transpose the dataframe. Please see: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.transpose.html



Edit:
Now i think I got what you need :)
Please try:


x_df.index.names = ['hour']
x_df.rename(columns='hour': 'counts', inplace=True)





If I transpose will it just transpose. My problem is that hour is above the count. As you can see, the hour 195 doesnt even exists. You can see the pic in the link ibb.co/buJkWU
– LisaSwiss
Aug 12 at 15:02






I have edited my answer. Please see if this is better now :)
– Dawid_Sielski
Aug 12 at 15:21






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard