df.fillna () не работает, но df.dropna () работает - PullRequest
0 голосов
/ 22 ноября 2018

В моем коде метод df.fillna () не работает, когда метод df.dropna () работает.Я не хочу бросать колонку, хотя.Что я могу сделать, чтобы метод fillna () работал?

def preprocess_df(df):
for col in df.columns:  # go through all of the columns
    if col != "target":  # normalize all ... except for the target itself!
        df[col] = df[col].pct_change()  # pct change "normalizes" the different currencies (each crypto coin has vastly diff values, we're really more interested in the other coin's movements)
        # df.dropna(inplace=True)  # remove the nas created by pct_change
        df.fillna(method="ffill", inplace=True)
        print(df)
        break
        df[col] = preprocessing.scale(df[col].values)  # scale between 0 and 1.

1 Ответ

0 голосов
/ 22 ноября 2018

Вы были почти там:

df = df.fillna(method="ffill", inplace=True)

Вы должны назначить его обратно в df

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...