WISH: [option to] make np.floor(), np.ceil(), np.trunc() etc return arrays with dtype=int
See original GitHub issueI’m trying to plot two quantities against each other but they are sampled at different intervals.
I tried plt.plot(array1, array2[np.floor(array1time / array2interval)])
.
However, np.floor
returns a float array so I need to cast the result to an integer type first.
This seems a bit silly. Is there any reason why someone would depend on the result of floor() being a floating point number?
Issue Analytics
- State:
- Created 10 years ago
- Comments:15 (14 by maintainers)
Top Results From Across the Web
Round up/down the elements of a ndarray (np.floor, trunc, ceil)
You can use np.floor() , np.trunc() , np.ceil() , etc. to round up and down the elements of a NumPy array ndarray ....
Read more >numpy.ceil — NumPy v1.24 Manual
If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to...
Read more >CuPy Documentation - Read the Docs
CuPy is a NumPy/SciPy-compatible array library for GPU-accelerated computing with Python. CuPy acts as a drop-in.
Read more >SciPy Reference Guide
Scipy and Numpy have HTML and PDF versions of their documentation ... mer command is array based and returns byte arrays of ones...
Read more >What's New — pandas 0.23.3 documentation - PyData |
With NumPy 1.15 and pandas 0.23.1 or earlier, numpy.all() will no longer reduce over ... Bug in Timestamp.ceil() and Timestamp.floor() when timestamp is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone would like a work-around, you can easily cast to an integer array after floor is called:
@jennirinker That’s a great suggestion. It does exactly what I originally wanted, is not any more verbose, and doesn’t require any changes to numpy. Thank you.