Since upgrading pandas I can no longer insert a row without a Future Warning. How to fix?

  Kiến thức lập trình

I have a dataframe with a well populated column of datetimes called “ds”. My intention is to insert one row before the others:

start = df_p['ds'].iloc[0] - pd.Timedelta(1,"d")
if start not in df_p.index:
    df_p.loc[start] = np.NaN

What I get is
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.

Obviously I am missing something dumb, but I can’t see it…

1

LEAVE A COMMENT