Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading