In order to print dataframes nicely using tabulate, so that NaN and NaT are printed as empty cells, I've been using this successfully:
print(tabulate(df.astype(object).fillna("")))
Now, this causes the following warning:
FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead.
I don't know what I should do instead now. I certainly don't see how infer_objects(copy=False) would help as the whole point here is indeed to force converting everything to a string representation and filling in missing values with empty strings.
I encountered the same issue today and I'm still looking for a fix myself. In your case, I must admit I don't know what calling
astype(object)twice does. However, as the error message mentions, you can try avoiding this and cast your data to strings instead (if that's feasible for the data you're handling). Then, you can use pd.DataFrame.replace like so:Of course, you probably want to adapt
to_replaceto include the NaN and NaT you're searching for. On my system,astype(str)convertsNaNtonan, so it might be similar for you andNaT.