Python Forum

Full Version: merge 2 dataset
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,
I have dataset1 that define the Trip Start Timestamp of each taxi trip made in Chicago in 2020
dataset1 has 2 columns:

Trip ID Trip Start Timestamp
7fa9327 2020-01-01
493354 2020-01-01
39100cd 2020-01-02
..... .......
d2941f 2020-09-30

dataset1['Trip Start Timestamp '] contain every date from 2020-01-01 to 2020-09-30 but also duplicates date cause in same date
there may have been multiple trips.
I have also dataset 2 that define amount(mm) of precipitation in each day from 2020-01-01 to 2020-09-30.
dataset2 has 2 columns:

DATE PRCP
2020-01-01 0.1
2020-01-02 0.8
2020-01-03 0.2
.......... ...
2020-09-30 0.3

It is a weather dataset independent of taxi trips so dataset 2['DATE'] contains every date from 2020-01-01 to 2020-09-30 and no duplicates date.
Now i want to add a column in dataset 1 that contains amount(mm) of prcp for each taxi trip made ,so for each row in dataset1
How can i do that? How is possible merge these 2 dataset with different rows in this particular way?
I try with concat, merge pandas function but with no success
i want something that do a for loop that :
for each row in dataset1['Trip Start Timestamp ] flows all rows in dataset2['DATE'] and if they are identically egual, print
dataset2['PRCP'] in correspondence of that row
Any suggestion?

I