@@ -733,6 +733,13 @@ def to_koalas(self):
733733 __index_level_0__ col1 col2
734734 0 0 1 3
735735 1 1 2 4
736+
737+ Calling to_koalas on a Koalas DataFrame simply returns itself.
738+
739+ >>> df.to_koalas()
740+ col1 col2
741+ 0 1 3
742+ 1 2 4
736743 """
737744 if isinstance (self , DataFrame ):
738745 return self
@@ -1298,33 +1305,45 @@ def sort_values(self, by, ascending=True, inplace=False, na_position='last'):
12981305 Examples
12991306 --------
13001307 >>> df = ks.DataFrame({
1301- ... 'col1': ['A', 'A', ' B', None, 'D', 'C'],
1302- ... 'col2': [2, 1, 9, 8, 7, 4],
1303- ... 'col3': [0, 1, 9, 4, 2, 3],
1308+ ... 'col1': ['A', 'B', None, 'D', 'C'],
1309+ ... 'col2': [2, 9, 8, 7, 4],
1310+ ... 'col3': [0, 9, 4, 2, 3],
13041311 ... })
13051312 >>> df
13061313 col1 col2 col3
13071314 0 A 2 0
1308- 1 A 1 1
1309- 2 B 9 9
1310- 3 None 8 4
1311- 4 D 7 2
1312- 5 C 4 3
1315+ 1 B 9 9
1316+ 2 None 8 4
1317+ 3 D 7 2
1318+ 4 C 4 3
13131319
13141320 Sort by col1
13151321
13161322 >>> df.sort_values(by=['col1'])
13171323 col1 col2 col3
13181324 0 A 2 0
1319- 1 A 1 1
1320- 2 B 9 9
1321- 5 C 4 3
1322- 4 D 7 2
1323- 3 None 8 4
1325+ 1 B 9 9
1326+ 4 C 4 3
1327+ 3 D 7 2
1328+ 2 None 8 4
13241329
1330+ Sort Descending
1331+
1332+ >>> df.sort_values(by='col1', ascending=False)
1333+ col1 col2 col3
1334+ 3 D 7 2
1335+ 4 C 4 3
1336+ 1 B 9 9
1337+ 0 A 2 0
1338+ 2 None 8 4
13251339
13261340 Sort by multiple columns
13271341
1342+ >>> df = ks.DataFrame({
1343+ ... 'col1': ['A', 'A', 'B', None, 'D', 'C'],
1344+ ... 'col2': [2, 1, 9, 8, 7, 4],
1345+ ... 'col3': [0, 1, 9, 4, 2, 3],
1346+ ... })
13281347 >>> df.sort_values(by=['col1', 'col2'])
13291348 col1 col2 col3
13301349 1 A 1 1
@@ -1333,17 +1352,6 @@ def sort_values(self, by, ascending=True, inplace=False, na_position='last'):
13331352 5 C 4 3
13341353 4 D 7 2
13351354 3 None 8 4
1336-
1337- Sort Descending
1338-
1339- >>> df.sort_values(by='col1', ascending=False)
1340- col1 col2 col3
1341- 4 D 7 2
1342- 5 C 4 3
1343- 2 B 9 9
1344- 0 A 2 0
1345- 1 A 1 1
1346- 3 None 8 4
13471355 """
13481356 if isinstance (by , string_types ):
13491357 by = [by ]
@@ -1496,7 +1504,10 @@ def _pd_getitem(self, key):
14961504 raise NotImplementedError (key )
14971505
14981506 def __repr__ (self ):
1499- return repr (self .toPandas ())
1507+ return repr (self .head (max_display_count ).to_pandas ())
1508+
1509+ def _repr_html_ (self ):
1510+ return self .head (max_display_count ).to_pandas ()._repr_html_ ()
15001511
15011512 def __getitem__ (self , key ):
15021513 return self ._pd_getitem (key )
@@ -1541,9 +1552,6 @@ def __dir__(self):
15411552 fields = [f for f in self ._sdf .schema .fieldNames () if ' ' not in f ]
15421553 return super (DataFrame , self ).__dir__ () + fields
15431554
1544- def _repr_html_ (self ):
1545- return self .head (max_display_count ).toPandas ()._repr_html_ ()
1546-
15471555 @classmethod
15481556 def _validate_axis (cls , axis = 0 ):
15491557 if axis not in (0 , 1 , 'index' , 'columns' , None ):
0 commit comments