df_state_group:
| Index | State | assigned_airport |
|---|---|---|
| 4 | Florida | NaN |
| 5 | Florida | NaN |
| 6 | Florida | NaN |
| 7 | Florida | NaN |
df1:
| Index | State | assigned_airport |
|---|---|---|
| 0 | Washington | NaN |
| 1 | New York | NaN |
| 2 | Illinois | NaN |
| 3 | Texas | NaN |
| 4 | Florida | NaN |
| 5 | Florida | NaN |
| 6 | Florida | NaN |
| 7 | Florida | NaN |
| 8 | Ohio | NaN |
| 9 | Colorado | NaN |
| 10 | Michigan | NaN |
| 11 | Indiana | NaN |
df_airports:
| Index | airports |
|---|---|
| 0 | a |
| 1 | b |
| 2 | c |
| 3 | d |
| 4 | e |
| 5 | f |
index_nearest_airport:
[3]
desired outcome:
df1:
| Index | State | assigned_airport |
|---|---|---|
| 0 | Washington | NaN |
| 1 | New York | NaN |
| 2 | Illinois | NaN |
| 3 | Texas | NaN |
| 4 | Florida | d |
| 5 | Florida | d |
| 6 | Florida | d |
| 7 | Florida | d |
| 8 | Ohio | NaN |
| 9 | Colorado | NaN |
| 10 | Michigan | NaN |
| 11 | Indiana | NaN |
df_state_group is a subset of df1 for the state of Florida
I have tried:
df1.loc[df_state_group.index, 'assigned_airport'] = df_airports.loc[index_nearest_airport,'airports'].values
but I keep on geting the error: ValueError: Must have equal len keys and value when setting with an iterable