Have a dataframe called topmentions
. Here some data relative to it:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 30 entries, 22 to 29
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 reference 30 non-null object
1 freq 30 non-null int64
dtypes: int64(1), object(1)
memory usage: 720.0+ bytes
None
reference freq
22 Giorgia Meloni|PER 4
16 Matteo Piantedosi|PER 3
10 Donald Trump|PER 3
28 Gianfranco Baruchello|PER 3
3 Tomaso Montanari|PER 3
Despite being a valid dataframe and despite the code below works as expected, the variable topmentions
gets flagged by Pylint as Value 'topmentions' is unsubscriptable
.
Here the code that gets flagged:
json_string = topmentions[
topmentions["freq"].cumsum() < topmentions["freq"].sum() / 2
].to_json(orient="records")
All three topmentions
variable names in the snippet are flagged as errors. What's wrong?
PS: I know I can suppress those errors adding # pylint: disable=unsubscriptable-object
, but I'd like not to resort to such a trick