'df.replace(np,nan) adding extra rows out of data frame length
I have data in txt file and the result of the count_row = df1.shape[0] is 13248.
I have derived column ['Seasonality'] from another df_all dataframe which is in total 2246 rows using the merger :
df2= pd.merge(df1,df_all[['PC9','Seasonality']], on='PC9', how='left')
In column ['Seasonality'] I have some NAN what I want to replace with NIS and Im doing this with code:
df2['Seasonality']=df2['Seasonality'].replace(np.nan,'NIS')
when I finally doing df2.to_csv
Desired out come should be 13248 rows in total but only ['Seasonality'] column goes until 14865 row with NIS filled in. Not sure what Im doing wrong
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
