@@ -64,37 +64,37 @@ NumPy's type system to add support for custom arrays
6464(see :ref: `basics.dtypes `).
6565
6666To get the actual data inside a :class: `Index ` or :class: `Series `, use
67- the ** array ** property
67+ the `` . array`` property
6868
6969.. ipython :: python
7070
7171 s.array
7272 s.index.array
7373
7474:attr: `~Series.array ` will always be an :class: `~pandas.api.extensions.ExtensionArray `.
75- The exact details of what an `` ExtensionArray ` ` is and why pandas uses them is a bit
75+ The exact details of what an :class: ` ~pandas.api.extensions. ExtensionArray ` is and why pandas uses them is a bit
7676beyond the scope of this introduction. See :ref: `basics.dtypes ` for more.
7777
7878If you know you need a NumPy array, use :meth: `~Series.to_numpy `
79- or :meth: `numpy .asarray `.
79+ or :meth: `np .asarray `.
8080
8181.. ipython :: python
8282
8383 s.to_numpy()
8484 np.asarray(s)
8585
8686 When the Series or Index is backed by
87- an :class: `~pandas.api.extension .ExtensionArray `, :meth: `~Series.to_numpy `
87+ an :class: `~pandas.api.extensions .ExtensionArray `, :meth: `~Series.to_numpy `
8888may involve copying data and coercing values. See :ref: `basics.dtypes ` for more.
8989
9090:meth: `~Series.to_numpy ` gives some control over the ``dtype `` of the
9191resulting :class: `ndarray `. For example, consider datetimes with timezones.
9292NumPy doesn't have a dtype to represent timezone-aware datetimes, so there
9393are two possibly useful representations:
9494
95- 1. An object-dtype :class: `ndarray ` with :class: `Timestamp ` objects, each
95+ 1. An object-dtype :class: `np. ndarray ` with :class: `Timestamp ` objects, each
9696 with the correct ``tz ``
97- 2. A ``datetime64[ns] `` -dtype :class: `ndarray `, where the values have
97+ 2. A ``datetime64[ns] `` -dtype :class: `np. ndarray `, where the values have
9898 been converted to UTC and the timezone discarded
9999
100100Timezones may be preserved with ``dtype=object ``
@@ -106,6 +106,8 @@ Timezones may be preserved with ``dtype=object``
106106
107107 Or thrown away with ``dtype='datetime64[ns]' ``
108108
109+ .. ipython :: python
110+
109111 ser.to_numpy(dtype = " datetime64[ns]" )
110112
111113 Getting the "raw data" inside a :class: `DataFrame ` is possibly a bit more
@@ -137,7 +139,7 @@ drawbacks:
137139
1381401. When your Series contains an :ref: `extension type <extending.extension-types >`, it's
139141 unclear whether :attr: `Series.values ` returns a NumPy array or the extension array.
140- :attr: `Series.array ` will always return an `` ExtensionArray ` `, and will never
142+ :attr: `Series.array ` will always return an :class: ` ~pandas.api.extensions. ExtensionArray `, and will never
141143 copy data. :meth: `Series.to_numpy ` will always return a NumPy array,
142144 potentially at the cost of copying / coercing values.
1431452. When your DataFrame contains a mixture of data types, :attr: `DataFrame.values ` may
0 commit comments