pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

[BUG] pandas 3.0 warning

Open lmeyerov opened this issue 1 year ago • 0 comments

Describe the bug

Triggered this warning in materialize_nodes() in pandas 2.2.2

/opt/conda/lib/python3.10/site-packages/graphistry/compute/ComputeMixin.py:135: 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.


  nodes_df[col].fillna(0, inplace=True)
/opt/conda/lib/python3.10/site-packages/graphistry/compute/ComputeMixin.py:135: 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.


  nodes_df[col].fillna(0, inplace=True)

Relevant line: https://github.com/graphistry/pygraphistry/blob/56d83dbe8764b4f01eaca2a6a848524cfa63e27f/graphistry/compute/ComputeMixin.py#L135

To Reproduce

import graphistry
import pandas as pd
edf = pd.DataFrame({
    's': ['a1', 'b2'],
    'd': ['b2', 'c1']
})
g = graphistry.edges(edf, 's', 'd').materialize_nodes().get_degrees()
g._nodes

Expected behavior

No warning

Actual behavior

Warning

Graphistry GPU server environment Pandas 2.2, PyGraphistry 0.34.3

lmeyerov avatar Sep 21 '24 03:09 lmeyerov