Home > Enterprise >  common_index is size 8783 and Series[common_index] is 8784, how is this even possible?
common_index is size 8783 and Series[common_index] is 8784, how is this even possible?

Time:04-05

common_index is a DatetimeIndex of length: 8783 When I use it to filter a Series object like this Series[common_index] I get a Series object of 8784 size.

Like how is it possible?

CodePudding user response:

Yes, it is possible if use duplicated values for select:

s = pd.Series(range(3), index=[0,1,5])

print (s[[0,1,0,5,5,5]])
0    0
1    1
0    0
5    2
5    2
5    2
dtype: int64

print (pd.unique([0,1,0,5,5,5]))
[0 1 5]

print (s[pd.unique([0,1,0,5,5,5])])
0    0
1    1
5    2
dtype: int64
  • Related