Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Apr 8, 2020

This PR proposes the DataFrame.truncate().

>>> df = ks.DataFrame({'A': ['a', 'b', 'c', 'd', 'e'],
...                    'B': ['f', 'g', 'h', 'i', 'j'],
...                    'C': ['k', 'l', 'm', 'n', 'o']},
...                   index=[1, 2, 3, 4, 5])
>>> df
   A  B  C
1  a  f  k
2  b  g  l
3  c  h  m
4  d  i  n
5  e  j  o

>>> df.truncate(before=2, after=4)
   A  B  C
2  b  g  l
3  c  h  m
4  d  i  n

The columns of a DataFrame can be truncated.

>>> df.truncate(before="A", after="B", axis="columns")
   A  B
1  a  f
2  b  g
3  c  h
4  d  i
5  e  j

For Series, only rows can be truncated.

>>> df['A'].truncate(before=2, after=4)
2    b
3    c
4    d
Name: A, dtype: object

@codecov-io
Copy link

codecov-io commented Apr 8, 2020

Codecov Report

Merging #1408 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1408   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files          34       34           
  Lines        7944     7949    +5     
=======================================
+ Hits         7548     7553    +5     
  Misses        396      396           
Impacted Files Coverage Δ
databricks/koalas/missing/frame.py 100.00% <ø> (ø)
databricks/koalas/series.py 96.92% <ø> (-0.05%) ⬇️
databricks/koalas/frame.py 96.61% <100.00%> (-0.01%) ⬇️
databricks/koalas/generic.py 96.96% <100.00%> (+0.21%) ⬆️

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 02b2577...04b691b. Read the comment docs.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Looks good otherwise.

@HyukjinKwon HyukjinKwon merged commit 7005e23 into databricks:master Apr 9, 2020
@itholic itholic deleted the f_truncate branch April 21, 2020 07:37
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.

3 participants