简体   繁体   中英

Getting an empty Pandas series when slicing by index

I have a pandas series

TimeUS
33715400    253.07
33715600    253.07
33715800    253.07
33716000    253.10
33716200    253.11
         ...  
34047400    253.15
34047600    253.04
34047800    252.89
34048000    252.90
40482000    252.95

I need to get a subset of this data, but when I call something like

s = data[33716200:]

I get an empty series. Why is this happening?

It seems to me that you want to slice using index but data[33716200:] will slice using row number. For index based slicing, try using data.loc[33716200:]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM