Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Check out our powerful new search update! You can read more here. Please let us know if you have any feedback by creating a topic here.

Changing the Index column within a pandas dataframe in Python

Highlighted
Atom

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!

Highlighted
ACE Emeritus
ACE Emeritus

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) 

Labels