Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

'Tis the season to be spooky! Read our new blog, How Spooky is Your City? Mapping and Predicting Scary Stuff. In it, @SusanCS provides a fun glimpse into using data to figure out the creepy quotient of where you live!

SOLVED

Changing the Index column within a pandas dataframe in Python

Highlighted
5 - 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
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) 

Highlighted
5 - Atom

That worked. Thank you @JohnJPS!

Labels