Résolue

Avertissement FutureWarning et opération inplace en pandas

# pandas

Frederic SEEMANN

A environ 4:00 de la vidéo, lorsque j'ai fait la manip chez moi j'ai eu ce message :

FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing df[col].method(value, inplace=True), try using df.method({col: value}, inplace=True) or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

df["tax"].fillna(0, inplace=True)

Gabriel Trouvé

Mentor

Salut :)

Et si tu fais ça à la place ?

df["tax"] = df["tax"].fillna(0)

Je suis tombé sur une issue, et apparemment le inplace serait plutôt à éviter maintenant : https://github.com/pyvista/pyvista/issues/4158

C'est le genre de changement que tu vas rencontrer avec les évolutions de versions. Avec Django, Wagtail etc... J'ai déjà eu des warnings du genre.

J'espère que j'ai pu t'aider !

Inscris-toi

(c'est gratuit !)

Inscris-toi

Tu dois créer un compte pour participer aux discussions.

Créer un compte

Rechercher sur le site

Formulaire de contact

Inscris-toi à Docstring

Pour commencer ton apprentissage.

Tu as déjà un compte ? Connecte-toi.