As the title implies I have converted two dictionaries into series like so and I tried to insert them into the data frame df.
first_series = pd.Series(first_dict, name='State Names')
second_series = pd.Series(second_dict, name='City Names')
column_loc=list(df.columns.values).index("ipAddr")
df.insert(column_loc+1, 'State Names', first_series)
df.insert(column_loc+2, 'City Names', second_series)
When I run this however I get
ipAddr State Names City Names ...
respID ...
10018 ***.**.**.** NaN NaN ...
10025 **.**.**.** NaN NaN ...
the series are as follows
10018 Bedford
10025 Vancouver
...
10267 Lompoc
10280 Pikesville
Name: State Names, dtype: object
--------------------------------------------------------
10018 Ohio
10025 Washington
...
10267 California
10280 Maryland
Name: City Names, dtype: object
I've checked that both the dictionaries and the resulting series are populated so I don't understand why this is occurring.
Thank you.
edit: A similar question got asked here but wasn't answered When I insert pandas Series into dataframe, all values become NaN
the index for both is the index of the data frame. I can't post the head of the data frame (character limit) but it is what's seen above. (apologies for the messy comment I'm new to stack and I don't know how to properly format yet) – MilesConn May 11 '17 at 22:04