Skip to content
Advertisement

Splitting columns and reformat date using pandas

I have an object, slist that I need to split, reformat the date, and export as a tab delimited file. For the splitting I think I’m tripping up understanding the first row? Here is slist:

enter image description here

I’ve tried the following:

JavaScript

Which gives me something like this:

enter image description here

I’ve spent a ton of time trying to figure this out and I know there are a lot of other pandas questions about column splitting, but I’ve hit a wall and any insight would be helpful. Thanks!

Advertisement

Answer

As you now have the datetime as row index, you can make it a data column by .reset_index() and then rename the columns, as follows:

JavaScript

Test Data Preparation

JavaScript

Run New Codes

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement