Skip to content

ENH: add Index.dropna #13791

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

Closed
wants to merge 1 commit into from
Closed

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jul 25, 2016

after this PR:

idx = pd.Index([1, 2, np.nan, 4])
idx.dropna()
# Float64Index([1.0, 2.0, 4.0], dtype='float64')

MI has option how to drop if any/all levels are NA (the same as DataFrame)

midx = pd.MultiIndex.from_arrays([[1, 2, np.nan, 4], [1, 2, np.nan, np.nan]])
midx.dropna()
# MultiIndex(levels=[[1, 2, 4], [1, 2]],
#            labels=[[0, 1], [0, 1]])

midx.dropna(how='all')
# MultiIndex(levels=[[1, 2, 4], [1, 2]],
#            labels=[[0, 1, 2], [0, 1, -1]])

@sinhrks sinhrks added Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Jul 25, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 25, 2016
@@ -323,6 +323,22 @@ Other enhancements
index=['row1', 'row2'])
df.sort_values(by='row2', axis=1)

- ``Index`` now supports ``.dropna`` to exclude missing values (:issue:`6194`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a sub section I think (and maybe roll some other API changes there from Index eg where) might be others

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or separate subsection. is fine too
whatever is more clear

@codecov-io
Copy link

codecov-io commented Jul 26, 2016

Current coverage is 85.24% (diff: 100%)

Merging #13791 into master will increase coverage by 0.01%

@@             master     #13791   diff @@
==========================================
  Files           140        140          
  Lines         50420      50438    +18   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          42975      42998    +23   
+ Misses         7445       7440     -5   
  Partials          0          0          

Powered by Codecov. Last update cc216ad...1672f26

idx.dropna()

For ``MultiIndex``, values are dropped if any level is missing by default. Specifying
``how='all'`` drops values to all levels are missing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" drops values to all levels are missing." -> "only drops values where all levels are missing"

@jorisvandenbossche
Copy link
Member

Two minor comments, looks good to me for the rest!

@sinhrks
Copy link
Member Author

sinhrks commented Jul 27, 2016

Thanks, made changes for that were pointed out. Added New Index method section under what's new -> enhancement to organize relevant fixes.

midx.dropna(how='all')

- ``Index.astype()`` now accepts an optional boolean argument ``copy``, which allows optional copying if the requirements on dtype are satisfied (:issue:`13209`)
- ``Index`` now supports ``.str.extractall()`` which returns a ``DataFrame``, the see :ref:`docs here <text.extractall>` (:issue:`10008`, :issue:`13156`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@jreback jreback closed this in dcb7bf7 Jul 29, 2016
@jreback
Copy link
Contributor

jreback commented Jul 29, 2016

thanks @sinhrks

@sinhrks sinhrks deleted the index_dropna branch July 29, 2016 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add dropna to Float64Index
4 participants