From d99dd565c0a1b5dc2ac9b33476bac4e652523e65 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 21 Dec 2019 12:32:21 +0100 Subject: [PATCH] Simplify intro tutorial re: asarray. DataFrames can also be converted to numpy arrays using np.asarray; no need to mention a separate way of converting them. --- tutorials/introductory/usage.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tutorials/introductory/usage.py b/tutorials/introductory/usage.py index 07e05dc09ad4..330627ba1c43 100644 --- a/tutorials/introductory/usage.py +++ b/tutorials/introductory/usage.py @@ -122,15 +122,11 @@ # # All of plotting functions expect `numpy.array` or `numpy.ma.masked_array` as # input. Classes that are 'array-like' such as `pandas` data objects -# and `numpy.matrix` may or may not work as intended. It is best to -# convert these to `numpy.array` objects prior to plotting. +# and `numpy.matrix` may or may not work as intended. It is best to use +# `numpy.asarray` to convert these to `numpy.array` objects prior to plotting:: # -# For example, to convert a `pandas.DataFrame` :: -# -# a = pandas.DataFrame(np.random.rand(4,5), columns = list('abcde')) -# a_asarray = a.values -# -# and to convert a `numpy.matrix` :: +# a = pandas.DataFrame(np.random.rand(4,5), columns=list('abcde')) +# a_asarray = np.asarray(a) # # b = np.matrix([[1, 2], [3, 4]]) # b_asarray = np.asarray(b)