You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here is that PythonCall intentionally does not define comparisons such as == between Python and non-Python objects, such as between df["country"] and "World". Hence df["country"] == "World" falls back to the default Julia behaviour of returning false.
You've got a few options:
Ensure both sides are Python objects: df["country"] == Py("World")
Use specific Python comparison functions: pyeq(df["country"], "World")
Use @py, which is equivalent to the previous line: @py df["country"] == "World"
thank you for pointing me to the @py macro. It works also together with the boolean indexing
julia>@py df[df["country"] =="World"]
Python DataFrame:
country year iso_code ... total_ghg_excluding_lucf trade_co2 trade_co2_share
49810 World 1750NaN...NaNNaNNaN49811 World 1751NaN...NaNNaNNaN49812 World 1752NaN...NaNNaNNaN49813 World 1753NaN...NaNNaNNaN49814 World 1754NaN...NaNNaNNaN........................50077 World 2017NaN...47031.8200.0040.050078 World 2018NaN...47980.469-0.004-0.050079 World 2019NaN...48116.5590.0000.050080 World 2020NaN...NaN0.0000.050081 World 2021NaN...NaN0.0000.0
[272 rows x 79 columns]
Uh oh!
There was an error while loading. Please reload this page.
fails because
df["country"] == "World"
returns plainlyfalse
It would be very awesome if we could just use normal pandas indexing syntax
The text was updated successfully, but these errors were encountered: