Pandas: How to handle pylint errors introduced by DataFrame.set_index's annotations in 1.5.0 release

Viewed 19

The annotations of dataframe's set_index method leads to pylint throwing an error, when accessing columns by []-notation. This is because pylint does not know, Nones are returned in inplace=True case only. This could be workarrounded by accessing by df.A but this would fail in inplace=True case either way. Can you please advise, how to best handle this issue?

import pandas as pd

df = pd.DataFrame([{"A": 1, "B": 2}]).set_index("B")
print(df.A)  # this wokrs
print(df['A'])  # this throws an pylint error
0 Answers
Related