Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

pandas date_range dataframe to column headers

Im new to python, and im attempting to create a date_range, convert the date_range to a DataFrame and convert each DataFrame row into a header. I have been perusing through the interwebs and cannot find a solution. It seems a simple problem, but i guess im to new to implement a simple solution. Any help is apreciated.
Here is what i have:

duration = pd.date_range(start='1/1/2022', periods=52, freq='W')
df = pd.DataFrame({'Date': duration})

Result:
RESULT

Need code for desired result:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Expected Result

>Solution :

Reflect the DataFrame over its main diagonal by writing rows as columns and vice-versa. The property T is an accessor to the method transpose().

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading