I have two Pandas dataframes. They all contain 3 decimal point float values.
Dataframe A is a one column dataframe with 12 rows. Dataframe B is a one column dataframe with over 40,000 rows, which contain the 12 values in Dataframe A spread out randomly.
I need to find the indices of the values in Dataframe A within Dataframe B.
I have tried .query()
, .index.value()
and .where()
but am unable to return the indices.
Row Index | Time |
---|---|
0 | 148.521 |
1 | 112.379 |
... | ... |
12 | 510.121 |
Row Index | Time |
---|---|
0 | 0.000 |
1 | 0.025 |
... | ... |
46871 | 1171.675 |
You can use df.loc[]
for i in dataframe_A['Time']:
dataframe_B.loc[dataframe_B['Time'] == i]
This should return the twelve values along with their row index from dataframe B
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.