Update: This function only avoids copy if it can, hence this is not the correct answer for this question. unutbu’s answer is the right one.
a = a.astype(numpy.float32, copy=False)
numpy astype has a copy flag. Why shouldn’t we use it ?
More Related Contents:
- Converting between datetime, Timestamp and datetime64
- Convert Python sequence to NumPy array, filling missing values
- numpy matrix vector multiplication [duplicate]
- Python out of memory on large CSV file (numpy)
- Conditionally fill column values based on another columns value in pandas
- How to convert an array of strings to an array of floats in numpy?
- How do I convert a PIL Image into a NumPy array?
- How do I remove NaN values from a NumPy array?
- selecting across multiple columns with python pandas?
- Getting data from ctypes array into numpy
- Fitting a Normal distribution to 1D data
- “In” operator for numpy arrays?
- Problem in combining bar plot and line plot (python)
- How to plot data from multiple two column text files with legends in Matplotlib?
- np arrays being immutable – “assignment destination is read-only”
- How to make a checkerboard in numpy?
- why isn’t numpy.mean multithreaded?
- PIP Install Numpy throws an error “ascii codec can’t decode byte 0xe2”
- vectorize conditional assignment in pandas dataframe
- Efficient way to partially read large numpy file?
- Pandas: How to create a datetime object from Week and Year?
- Binning a column with pandas
- Convert numpy type to python
- How to update matplotlib’s imshow() window interactively?
- Screen Capture with OpenCV and Python-2.7
- Find the index of the k smallest values of a numpy array
- Concatenate range arrays given start, stop numbers in a vectorized way – NumPy
- Principal component analysis in Python
- Numpy – Replace a number with NaN
- Numpy: use reshape or newaxis to add dimensions