Skip to content
Advertisement

Create new columns based on previous columns with multiplication

I want to create a list of columns where the new columns are based on previous columns times 1.5. It will roll until Year 2020. I tried to use previous and current but it didn’t work as expected. How can I make it work as expected?

JavaScript

Advertisement

Answer

IIUC you can fix you code with:

JavaScript

Another, vectorial, approach with numpy would be:

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement