0

I have a series, Data that has the following data:

timestamp                
02-12-2013 12:00:12        1.2
02-12-2013 14:00:00        1.4
02-13-2013 16:05:12        1.7 
02-15-2013 16:05:12        1.7 

I'm trying to subset the data by data[data.index == '02-12-2013'] and it only returns the first instance. May I know how can I obtain all rows that have the specified date?

tech bitz
  • 11
  • 4

1 Answers1

0

Have you tried pandas.DataFrame?

import pandas as pd

aaa = ['02-12-2013', '02-12-2013', '02-13-2013', '02-15-2013']
bbb = ['12:00:12', '14:00:00', '16:05:12', '16:05:12']
ccc = [1.2, 1.4, 1.7, 1.7]

df=pd.DataFrame([bbb,ccc],columns=aaa)

The result will be:

df["02-12-2013"]

  02-12-2013 02-12-2013
0   12:00:12   14:00:00
1        1.2        1.4

If you want a row, just transpose it

df["02-12-2013"].T

                   0    1
02-12-2013  12:00:12  1.2
02-12-2013  14:00:00  1.4
  • thanks Kevin. Im just curious how it works in a Series – tech bitz Feb 26 '22 at 15:25
  • Just a quick one, about subsetting your data to find data, you can check this out https://stackoverflow.com/a/12098586/16836078 –  Feb 26 '22 at 15:30