Request for Solution

I am new in Python

i got a very agent problem about python for my project.

My task is to replace the xlookup function on excel by using python.

Let me simply explain my task, i got thousands of data in 2 differences excel file, lets call FileA and FileB. I need to insert the data, let say “Temperature” from a column in FileB to FileA.

The array I use to compare is in datetime types, but the datetime in FileA is in (DD/MM/YYYY HH:MM:SS) types for example : ‘01/03/2021 15:12:58 PM’ while in FileB is in (HH:MM:SS) types for example: ‘15:12:58 PM’

But in FileB, the time is faster than the time in FileA for about 2s, which mean mightbe can’t get the same value of datetime likes ( 15:12:58 PM ) in FileB and (01/03/2021 15:12:58 PM ) in FileA

Mightbe we will see (15:12:58 PM ) in FileB and (01/03/2021 15:12:56 PM ) in FileA but the value of the ‘temperature’ mightbe the one that I want to insert In.

Let me explain more detail. By using excel xlookup, we r going to insert (lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]))

In my case:

Lookup_value = datetime in (DD/MM/YYYY HH:MM:SS) format from FileA

Lookup_array = Temperature in number format from FileB

Return_array = Temperature column that are empty in FileA

[if_not_found] = not found

Match_mode = - 1 (if not found the same value
of datetime from both file, it will get the
closest time, means if for now data is
(01/03/2021 15:12:56 PM) in FileA and can’t
get the same time in FileB, than it will
automatically get the nearest upper time
from FileB.)

Search_mode = 1 (search from 1 row to last row)

Therefore, the second problem is how to find out the same time for both file.

Actually I am an intern in a company and they give me a task and program python that I never know b4. Do you have any idea or solution about this? I really need help in this problem. Hope that you can help me in this and give me some ideas about this. Thank you for your patient to read this message and I really apologise for disturbing you. I really can’t get the ideas from other websits.:pensive:

Hi! Have you looked into using pandas at all?
With pandas, you could split the column that is date/time into just time, and then compare the two time columns to each other.
Pandas is super handy for spreadsheet-type stuff, and once you get the hang of a few tricks, is quite easy to do things like sort, find averages/max/min/median, and a lot more.