at first I'd like to let you know, that python is just a tool for me, for a side project that I currently work on. I have nothing to do with programming, I learn everything ad hoc, so I'd really appreciate, if you kept this as simple as possible.
So far I managed to process and write my data into 2 csv files, which look like this:
- Police.csv:
gmina, datetime
1, 2008-01-02 12:00:00
1, 2008-01-02 12:00:00
1, 2008-01-02 16:00:00
1, 2008-01-02 16:00:00
1, 2008-01-06 09:00:00
1, 2008-01-06 15:00:00
1, 2008-01-06 20:00:00
1, 2008-01-06 21:00:00
'gmina' goes from 1 to 10 with multiple dates
- meteo.csv:
station, datetime, visibility
12100, 2000-01-09 14:00:00, 900.0
12100, 2000-01-09 15:00:00, 900.0
12100, 2000-01-16 06:00:00, 900.0
12100, 2000-01-16 07:00:00, 600.0
12100, 2000-01-16 08:00:00, 900.0
12100, 2000-01-16 12:00:00, 900.0
12100, 2000-01-16 13:00:00, 600.0
There are 10 different values for 'station'. Number of rows is different for both csv.
What I want to do now, is to find rows with the exact same date and hour, write them into new csv, but only for pairs of keys and values like: 'gmina': '1' and 'station': '12100'; 'gmina': '2' and 'station': '12105' and so on. I reckon I need a dictionary for that. I found something like this: Python: Comparing two CSV files and searching for similar items. I need something similar, only with this additional condition of matching values from 'gmina' and 'station'. Could you please give me a hint how to implement this condition in above's code? Or maybe it'd be easier to parse those csv files into dataframes and work with pandas?