I am basically trying to write my results in csv file. However, the amount of row numbers in each column is different. when it is written, values stop at the minimum row number, however, I have still values in the other column but don't write them.
For example, HYG_FT01 produces 100 values and HYG_PU12_PW produces 140 values after the calculation.
When it comes to writing in CSV file, I see 100 values in each column for both.
I used df.append
function, and got same problem. Also changed ffill
to bfill
but, did not work.
Here is my code:
features = ['HYG_FT01', 'HYG_PU12_PW_PV']
df = pd.read_csv('HYG_2021_08.csv', usecols=features, sep=';', encoding='ISO-8859-1')
for features in df:
new_df = df[[features]].quantile(q=.99, axis=0, numeric_only=True)
df.drop(df[df[features] > new_df.iloc[0]].index, inplace=True)
print(df[features].describe())
df.replace([features], method='ffill').to_csv('trials.csv', index=False)