Last answered:

21 May 2023

Posted on:

08 Jun 2022

0

FutureWarning - Future version of Pandas

Hello. I am getting this warning frequently. Does it matter? Do I need to do something to fix it?



image

3 answers ( 0 marked as helpful)
Instructor
Posted on:

09 Jun 2022

1

Hey Sandra,

Thank you for your question!

Here is the documentation of pandasconcat() method. Notice that the first two arguments that you need to provide when using it are objs and axis. In the warning message, you are told that the warning occurs because of this line of code:

x = pd.concat(x[::order], 1)

Here, it is implied that the first argument is objs and the second one is axis. However, as the message reads, that will not be the case in future pandas versions. You would need to write the keywords explicitly (except for objs), that is:

x = pd.concat(x[::order], axis = 1)



Now, you are not calling pandasconcat() method in your code, right? So, why is Python complaining? :) It complains because you are calling statsmodels' add_constant() method which makes use of this method to complete its task. Therefore, the problem is, in fact, in the implementation of the statsmodels library.

There are two ways to solve this issue. The first one is passive - wait for the statsmodels developers to solve the problem in a future version (if they haven't already) :) The second one is active - go to the source code and correct this line of code alone! Why not? :) The warning message tells you exactly the path where the Python script is, namely:

/opt/anaconda3/lib/python3.9/site-packages/statsmodels/tsa/tsatools.py:142

Once you find the tsatools.py file, you can open it with a text editor or a Python editor of your choice - I used Spyder. Locate the 142nd line of code - the warning message tells you where in the code exactly the problem is:
image.png
Now, go ahead and change it to
image.png
Save the file, close it, go back to the Jupyter notebook and restart the kernel as follows:
image.png
Then, run all the cells anew. The warning should be gone :)

Hope this helps!

Kind regards,
365 Hristina

Posted on:

09 Jun 2022

0

Awesome! It works perfectly!!
Thank you so much.

Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

21 May 2023

0

Wonderful explanation Hristina Hristova, Sometimes it would be great to have a look at problems or questions raised by others like this we got tons of information other than course as we can actually change source code to our need 

Submit an answer