Hi all,
Below is a dataframe I was able to create with 5 stocks and their free cash flows withing the research environment. However, I want to melt the dataframe along the dates given in the first column. As a result, I want a dataframe with the date, stock, and free cash flow columns in that order. How would I proceed with the coding in QuantConnect's research environment?
Thank you.
Hector Barrio
Ari,
this is related to the pandas version the research environment is running, in pandas 1.1 the following code might work:
free_cash_flow.melt(ignore_index=False)
Research environment runs 0.25.3 and something like this may return the dataframe you need:
free_cash_flow.unstack().reset_index().rename(columns = {'level_0': 'symbol', 0:'FCF'}).set_index(['time','FCF'])
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Ari Sondhi
Hi Hector,
I tried both of your suggestions but neither seemed to work. Are there any other ideas you may have regarding this issue?
The first suggestion comes back with the following error:
melt() got an unexpected keyword argument 'ignore_index'The second suggestion comes back with: "None of ['time'] are in the columns"The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!