NaN values when new column added to pandas DataFrame

Because the indexes are not exactly equal, NaNs will result. Either one or both of the indexes must be changed to match. Example:

mydata = mydata.set_index(DWDATA.index)

The above will change the index of the ‘mydata’ DataFrame to match the index of the ‘DWDATA’ DataFrame.

Since the number of rows are exactly equal for the two DataFrames, you can also just pass the values of ‘mydata’ to the new ‘DWDATA’ column:

DWDATA['MXX'] = mydata.iloc[:,0].values

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.