1

The column is of type str with format like 2018-10-10, and has no nan values.

print(df['col'].isna().sum()) # 0
print(df['col'].max()) # nan

min() on the other hand shows the correct value

print(df['col'].min()) # 2018-01-01

Why is max() reporting nan value?

Snow
  • 1,058
  • 2
  • 19
  • 47

1 Answers1

1

I think there is at least one string nan, you can test it:

print (df[df['col'] == 'nan'])

max function in python/pandas working with strings also and returns the one that is at the bottom of the alphabetic list, check this.

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • you're right. How come `df['col'].isna().sum()` doesn't show it? Maybe because `nan` is not interpreted as `NaN`? – Snow Oct 04 '19 at 11:42
  • No, because `ìsna` testing only missing values, not strings `nan`s – jezrael Oct 04 '19 at 11:43