1👍
✅
You could go through the row indices
communes = [
Commune(
id = tmp_data.loc[row]['id'].tolist(),
uuid = tmp_data.loc[row]['uuid'].tolist(),
name = tmp_data.loc[row]['name'].tolist(),
geohash_file = tmp_data.loc[row]['geohash_file'].tolist(),
gps_lat_file = tmp_data.loc[row]['gps_lat_file'].tolist(),
gps_long_file = tmp_data.loc[row]['gps_long_file'].tolist(),
code_insee = tmp_data.loc[row]['code_insee'].tolist(),
code_postal = tmp_data.loc[row]['code_postal'].tolist(),
code_postal2 = tmp_data.loc[row]['code_postal2'].tolist(),
)
for row in range(tmp_data.shape[0])
]
Or you could go through the id’s
communes = [
Commune(
id = tmp_data.loc[tmp_data["id"]==i]['id'].iloc[0],
uuid = tmp_data.loc[tmp_data["id"]==i]['uuid'].iloc[0],
name = tmp_data.loc[tmp_data["id"]==i]['name'].iloc[0],
geohash_file = tmp_data.loc[tmp_data["id"]==i]['geohash_file'].iloc[0],
gps_lat_file = tmp_data.loc[tmp_data["id"]==i]['gps_lat_file'].iloc[0],
gps_long_file = tmp_data.loc[tmp_data["id"]==i]['gps_long_file'].iloc[0],
code_insee = tmp_data.loc[tmp_data["id"]==i]['code_insee'].iloc[0],
code_postal = tmp_data.loc[tmp_data["id"]==i]['code_postal'].iloc[0],
code_postal2 = tmp_data.loc[tmp_data["id"]==i]['code_postal2'].iloc[0],
)
for i in tmp_data["id"]
]
👤Vons
Source:stackexchange.com