Skip to content
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

Implement Series.first_valid_index #936

Merged
merged 6 commits into from
Oct 28, 2019

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Oct 17, 2019

Like pandas Series.first_valid_index (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.first_valid_index.html#pandas.Series.first_valid_index)

implemented function first_valid_index for Series.

>>> s = ks.Series([None, None, 3, 4, 5], index=[100, 200, 300, 400, 500])
>>> s
100    NaN
200    NaN
300    3.0
400    4.0
500    5.0
Name: 0, dtype: float64

>>> s.first_valid_index()
300
>>> s.to_pandas().first_valid_index()
300

And act like below when Series has MultiIndex

>>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],
...                       ['speed', 'weight', 'length']],
...                      [[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                       [0, 1, 2, 0, 1, 2, 0, 1, 2]])
>>> s = ks.Series([None, None, None, None, 250, 1.5, 320, 1, 0.3], index=midx)
>>> s
lama    speed       NaN
        weight      NaN
        length      NaN
cow     speed       NaN
        weight    250.0
        length      1.5
falcon  speed     320.0
        weight      1.0
        length      0.3
Name: 0, dtype: float64

>>> s.first_valid_index()
('cow', 'weight')
>>> s.to_pandas().first_valid_index()
('cow', 'weight')

@codecov-io
Copy link

codecov-io commented Oct 17, 2019

Codecov Report

Merging #936 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #936      +/-   ##
==========================================
+ Coverage   94.52%   94.53%   +<.01%     
==========================================
  Files          34       34              
  Lines        6465     6472       +7     
==========================================
+ Hits         6111     6118       +7     
  Misses        354      354
Impacted Files Coverage Δ
databricks/koalas/missing/series.py 100% <ø> (ø) ⬆️
databricks/koalas/series.py 96.14% <100%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8dcb64...bad5c3f. Read the comment docs.

databricks/koalas/series.py Outdated Show resolved Hide resolved
@HyukjinKwon
Copy link
Member

Looks fine otherwise.

@softagram-bot
Copy link

Softagram Impact Report for pull/936 (head commit: bad5c3f)

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

📄 Full report

Impact Report explained. Give feedback on this report to [email protected]

@HyukjinKwon HyukjinKwon merged commit 489d781 into databricks:master Oct 28, 2019
@itholic itholic deleted the s_first_valid_index branch November 6, 2019 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants