1

I am trying to plot the following array:

array(['2019-08-23 16:24:55.000', '2019-08-23 15:51:07.000',
       '2019-08-23 15:41:30.000', '2019-08-23 15:36:45.000',
       '2019-08-23 13:54:36.000', '2019-08-23 11:32:04.000',
       '2019-08-23 11:15:20.000', '2019-08-23 11:07:46.000',
       '2019-08-23 10:51:20.000', '2019-08-23 10:51:19.000',
       '2019-08-23 10:33:24.000', '2019-08-23 09:50:18.000',
       '2019-08-23 08:21:51.000', '2019-08-22 11:50:55.000',
       '2019-08-22 11:36:52.000', '2019-08-22 11:31:24.000',
       '2019-08-22 09:56:18.000', '2019-08-21 21:42:50.000',
       '2019-08-21 21:11:08.000', '2019-08-21 21:09:18.000',
       '2019-08-21 21:04:52.000', '2019-08-21 20:57:57.000',
       '2019-08-21 20:27:09.000', '2019-08-21 20:06:50.000',
       '2019-08-21 20:01:00.000', '2019-08-21 19:50:41.000',
       '2019-08-21 17:53:00.000', '2019-08-21 17:38:45.000',
       '2019-08-21 16:37:32.000', '2019-08-15 14:04:18.000',
       '2019-08-15 13:42:21.000', '2019-08-15 13:36:25.000',
       '2019-08-15 13:27:50.000', '2019-08-15 13:22:55.000'], dtype='<U23')
sns.distplot(nx)
/opt/conda/lib/python3.6/site-packages/numpy/core/_methods.py in _mean(a, axis, dtype, out, keepdims)
     73             is_float16_result = True
     74 
---> 75     ret = umr_sum(arr, axis, dtype, out, keepdims)
     76     if isinstance(ret, mu.ndarray):
     77         ret = um.true_divide(

TypeError: cannot perform reduce with flexible type

Is there a way to plot such array?

1 Answer 1

1

I'm not fully sure of what you try to do, but I would say you need to convert your array to representative integers then you can plot. So convert to datetime and then integer:

sns.distplot(nx.astype('datetime64[s]').astype('int'))

enter image description here

Now if you want to have the date back to the x-axis, maybe do:

g = sns.distplot(nx.astype('datetime64[s]').astype('int'))
g.set_xticklabels(ax.get_xticks().astype('datetime64[s]').astype('datetime64[D]'), rotation=20)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.