In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Changing the Index column within a pandas dataframe in Python

rborger
7 - Meteor

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!

2 REPLIES 2
JohnJPS
15 - Aurora

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) 

rborger
7 - Meteor

That worked. Thank you @JohnJPS!

Labels
Top Solution Authors