Why Do I Get A 'FutureWarning' With Pandas.concat?
Solution 1:
Most function parameters in python are "positional or keyword" arguments.
I.e. if I have this function:
def do_something(x, y):
pass
Then I can either call it like this, using positional arguments:
do_something(1, 2)
Or like this, using keyword arguments:
do_something(x=1, y=2)
Or like this, using a mixture of the two (but note that you're not allowed to have a positional argument after a keyword argument):
do_something(1, y=2)
But you can also define functions with positional-only or keyword-only parameters
Say I have this other function:
def do_something_else(x, /, y, *, z):
pass
In this function, I've marked x
as being positional-only, because it comes before the /
. And I've marked z
as being keyword-only, because it comes after the *
. y
is a positional-or-keyword parameter, as it comes after the /
but before the *
. This means that these two attempts to call the function will fail: the first one because z
is being called as a positional argument, and the second because x
is being called as a keyword argument:
do_something_else(1, 2, 3) # will fail!
do_something_else(x=1, y=2, z=3) # will fail!
These two attempts, however, will both succeed — y
is still a positional-or-keyword parameter.
do_something_else(1, 2, z=3) # fine
do_something_else(1, y=2, z=3) # fine
The `FutureWarning` message.
The FutureWarning
message has nothing to do with the version of python you're using, but has everything to do with the version of pandas
that you're using. Pandas
is a third-party library, not a part of the python core, so the pandas
version you're using is a completely different thing to the python version you're using.
The warning is letting you know that currently, you're fine to write pd.concat(dfs, self._concat_axis)
, but that they're planning on changing the definition of the function in a future version of pandas
so that all arguments except for objs
will be keyword-only. I.e., after they make this change, pd.concat(dfs, self._concat_axis)
will raise an error, and you will have to write pd.concat(dfs, axis=self._concat_axis)
instead. They are most likely considering making this change because calling functions with keyword arguments is often clearer and more readable for other people.
Solution 2:
Don't worry about futurewarnings, it won't affect your code in any ways. But try to avoid this kind of warnings, because in future this warning will not be shown instead gives error as pandas gets updated. That's why it shows future warning.
Post a Comment for "Why Do I Get A 'FutureWarning' With Pandas.concat?"