How to read specific time for specific value row by row using python
One-liner:

result = data.loc[data.x == 4, "time"]    # assuming you expect just the time as output




Explanation

To describe your problem, first in English (then code):


  You want the rows of the data frame, where the value of the X column is 4, and all columns should be included in the result.


To check where coilumn X is 4, we can do this:

data.X == 4


This returns True or False for every single row. Now we can use this as a filter, by passing it to the pandas DataFrame's .loc accessor (loc = "locate").

result = data.loc[data.X == 4, :]
# Notation: dataframe[rows_we_want, columns_we_want]


Because we want all columns, we have left the colon : in there after the comma. Pandas assumes you want all columns by default, so we can actually leave it out to get the one-liner given above.

So if you just want to time to be given as output, you can filter for that by putting the name of the column after the comma:

result = data.loc[data.X == 4, "time"]