Plotly.express charts ignore negative values in dataframes

Hi all.

I’ve discovered a pretty strange behaviour in plotly.express charts: they ignore negative values in pandas dataframes completely.

For instance, I create a plotly.express chart with a dataframe.

df = pd.read_sql(sql, engine)
fig= px.pie(dff, values=‘fatt_netto’, names=‘classe1’, title=‘FN’)

Then I load my pie chart inside a dash app.
If, for instance, I select the ‘AUDIO’ category I get a value for ‘fatt_netto’ of 1,534,980.83

plotly.err


But if I query the database I get a different value:
plotly.err2


If I don’t select the negative values I get 1,534,980.83
plotly.err3


If I check dataframe I pass to px.pie I see that dff does contains the negative values

print(dff[dff[‘fatt_netto’] < 0])
fig= px.pie(dff, values=‘fatt_netto’, names=‘classe1’, title=‘FN’)

plotly.err4


And to be more precise, If I sum the negative values I get exactly the difference -33,317.6

a = dff[dff['fatt_netto'] < 0]
print(a.groupby(['classe1']).sum())

plotly.err6


1,501,663.23 - 1,534,980.83 = -33,317.6

plotly.err5


That is, the plotly.express chart is ignoring the negative values in the dataframe all together.
How do you handle these negative values?
How do I have to configure plotly to handle negative values?

Many thanks for your time.

Kind regards.

Gius.