0

I am trying to iterate through a list of timestamps from SQLite3 (sql_min) to find matching values in a Pandas column (df['Timestamp']) and then return the corresponding row number (df['date_index'])

for item in sql_min:
    index = df.loc[df['Timestamp'] == item, 'date_index']
    print(index)

I hoping to return an integer of the row number but get Series([], Name: date_index, dtype: int32) or ValueError: Lengths must match to compare

1 Answer 1

1

If you consider Timestamp as string you can try the following:

for item in sql_min:
    indx = df.date_index[df.index[df.timestamp.str.contains(item)]]
    print(indx.to_string(index=True))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.