Open soylander opened 1 year ago
Thanks for the report.
We need to create some consistency between the indexing used in DataFrame._LocIndexerFrame.__getitem__()
, Series.__getitem__()
and Series._LocIndexerSeries.__getitem__()
. If you use:
df = pd.DataFrame(s)
df.loc[dt1, :]
df.loc[[dt1], :]
that is accepted. If you use
df = pd.DataFrame({"x": s})
df.loc[dt1, "x"]
df.loc[[dt1], "x"]
you get typing errors.
Describe the bug Pylance shows error when using a timestamp as label for selecting data from a pandas series.
To Reproduce
pandas
example that is not properly checked by the stubs.dt1 = pd.to_datetime('2023-05-01') dt2 = pd.to_datetime('2023-05-02') s = pd.Series([1, 2], index=[dt1, dt2]) s[dt1] # pylance error here s.loc[[dt1]] # pylance error here also