8000 ENH: add ExtensionArray.to_numpy to have control over conversion to numpy array by jorisvandenbossche · Pull Request #30322 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: add ExtensionArray.to_numpy to have control over conversion to numpy array #30322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dataframe
  • Loading branch information
TomAugspurger committed Jan 3, 2020
commit f1e34c6169d0b5b939aeb5dcb0135f4a3dcc005b
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Other enhancements
^^^^^^^^^^^^^^^^^^

- :meth:`DataFrame.to_string` added the ``max_colwidth`` parameter to control when wide columns are truncated (:issue:`9784`)
- Added the ``na_value`` argument to :meth:`Series.to_numpy` and :meth:`Index.to_numpy` to control the value used for missing data (:issue:`30322`)
- Added the ``na_value`` argument to :meth:`Series.to_numpy`, :meth:`Index.to_numpy` and :meth:`DataFrame.to_numpy` to control the value used for missing data (:issue:`30322`)
- :meth:`MultiIndex.from_product` infers level names from inputs if not explicitly provided (:issue:`27292`)
- :meth:`DataFrame.to_latex` now accepts ``caption`` and ``label`` arguments (:issue:`25436`)
- The :ref:`integer dtype <integer_na>` with support for missing values and the
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ def test_to_numpy_na_values(self):
tm.assert_numpy_array_equal(result, expected)
tm.assert_frame_equal(df, original)

result = df.to_numpy(dtype="int", na_value=0)
expected = np.array([[1, 0, 3]]).T
tm.assert_numpy_array_equal(result, expected)
tm.assert_frame_equal(df, original)

def test_to_numpy_na_value_heterogenous(self):
df = pd.DataFrame({"A": [1, None, 3], "B": ["a", None, "c"]})
original = df.copy()
Expand Down
0