array.min() <= array[0] --> return false

Viewed 46

As described in the title. The value in question is min of red. ath returns the expected result for both min and max. The elements are datetime.date. I did some experiments to explain this situation but it becomes even more confusing. This almost sounds fake, so I attached the screenshot of the notebook.

[In]
(red.shipped_date.values.min(), red.shipped_date.values.max())
(ath.created_date.values.min(), ath.created_date.values.max())
[Out]
(datetime.date(2021, 1, 10), datetime.date(2021, 7, 6))
(datetime.date(2016, 1, 1), datetime.date(2021, 6, 23))

[In]
red.shipped_date.values.min()
[Out]
datetime.date(2021, 1, 10)

[In]
red.shipped_date.values[0]
[Out]
datetime.date(2018, 7, 25)

[In]
red.shipped_date.values.min() > red.shipped_date.values[0]
[Out]
True

[In]
(red.shipped_date.values).min() == (red.shipped_date.values)[0]
[Out]
False

[In]
# I want to see if the array only searched for the first n values and that's why? 
np.where(red.shipped_date.values == red.shipped_date.values.min())
[Out]
(array([ 21769,  22728,  22730,  64642,  64643,  71007,  71008, 140756,
        140757, 154368, 154369, 154372, 154373, 154376, 154377, 154544,
        156998, 157003, 157004, 157006, 157007, 158041, 158042, 160156,
        160157, 161450, 161451]),)

[In]
# If there is no so-called min() in the array, will it recognize the true minimum?
first_min = red.shipped_date.values[:21769]
first_min.min()
[Out]
datetime.date(2016, 1, 4)
# Yes. This output is expected.

[In]
red.shipped_date.values[0] < red.shipped_date.values.min()
[Out]
True

[In]
# If we include the so-called min(), will that still be the min()?
inc_first_min = red.shipped_date.values[:21769+1]
inc_first_min.min()
[Out]
datetime.date(2016, 1, 4)
# This is expected.

[In]
# After getting rid of all so-called min() values, what would be the min() of the array?
red.shipped_date.values[np.where(red.shipped_date.values != red.shipped_date.values.min())].min()
[Out]
datetime.date(2021, 1, 11)

above

0 Answers
Related