I have these two dataframe: 1) data here are grouped by station_id( from 1 up to 98) and time( a data every hour from 27-01-2020 to 26-05-2020)
- In the second dataframe I have a latitude and longitude value for every station_id.
My aim is to create a list of list in this format:
latitude longitude flow hour month day
[[53.37947845458979, -1.46990168094635, 278.0, 0.0, 1.0, 27.0],
[53.379791259765604, -1.46999669075012, 122.0, 0.0, 1.0, 27.0],
[53.380035400390604, -1.47001004219055, 58.0, 0.0, 1.0, 27.0], ...]
In order to have a list [latitude, longitude, flow, month, day] for every row in the first dataframe. I tried with the following code:
import pandas as pd
import datetime as dt
df = pd.read_csv("readings_by_hour.csv")
df['time'] = pd.to_datetime(df['time'])
df1 = pd.read_csv("stations_info.csv")
i = 0
a = []
b = []
count = df1['station_id'].count()
while i < count:
if df['station_id'][i] == df1['station_id'][i]:
a = print(df1['latitude'][i] + ", " + df1['longitude'][i] + ", " + df['flow'][i] + ", " + df['time'].dt.hour + ", " + df['time'].dt.month + ", " + df['time'].dt.day)
b += [a]
i += 1
print(b)
but it seems it doesn't work, indeed didn't giving any output though it didn't give any error.

