Changing the Index column within a pandas dataframe in Python
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello all,
I am having trouble outputting the results of a stock market analysis I am attempting to complete using Python within Alteryx.
In this example, I currently have successfully run a function from pandas_datareader to pull all results for one security during 2019. Unfortunately, the date column is output as the index column, which goes away when I run the Alteryx.write() command (see attached snip).
Could someone please point me in the right direction how to work around this issue so that the date column makes it into the Alteryx workflow?
Apologies for the elementary way of showcasing my code but wasn't sure how to attach the full results to this post.
Thanks!
Solved! Go to Solution.
- Labels:
- Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It looks like the dates are actually the index of the data frame... try the following:
df = df.assign(date=df.index.date)
(See this link for a little more detail)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
That worked. Thank you @JohnJPS!
