Numpy vectorization messes up data type (2)

前端 未结 3 1115
小蘑菇
小蘑菇 2020-12-21 06:22

I\'m having unwanted behaviour come out of np.vectorize, namely, it changes the datatype of the argument going into the original function. My original question

3条回答
  •  再見小時候
    2020-12-21 07:02

    Just as in the original question, I can "solve" the problem by forcing the incoming argument to be a pandas datetime object, by adding dt = pd.to_datetime(dt) before the first if-statement of the function.

    To be honest, this feels like patching-up something that's broken and should not be used. I'll just use .apply instead and take the performance hit. Anyone that feels there's a better solution is very much invited to share :)

提交回复
热议问题