A Distributed Data Frame, the basic abstraction in DistributedDataFrame library.
| 6 | |
| 7 | |
| 8 | class DistributedDataFrame(object): |
| 9 | """ |
| 10 | A Distributed Data Frame, the basic abstraction in DistributedDataFrame library. |
| 11 | """ |
| 12 | |
| 13 | def __init__(self, jddf): |
| 14 | """ |
| 15 | Constructor |
| 16 | """ |
| 17 | self._jddf = jddf |
| 18 | |
| 19 | ########################################################################### |
| 20 | |
| 21 | @property |
| 22 | def colnames(self): |
| 23 | """ |
| 24 | List the column names of this DDF |
| 25 | |
| 26 | :return: a list of strings |
| 27 | """ |
| 28 | return self._jddf.getColumnNames() |
| 29 | |
| 30 | @property |
| 31 | def rows(self): |
| 32 | """ |
| 33 | Get number of rows of this DDF |
| 34 | |
| 35 | :return: an int |
| 36 | """ |
| 37 | return int(self._jddf.getNumRows()) |
| 38 | |
| 39 | @property |
| 40 | def cols(self): |
| 41 | """ |
| 42 | Get number of columns of this DDF |
| 43 | |
| 44 | :return: an int |
| 45 | """ |
| 46 | return int(self._jddf.getNumColumns()) |
| 47 | |
| 48 | ########################################################################### |
| 49 | |
| 50 | def head(self, n=10): |
| 51 | """ |
| 52 | Return this DistributedDataFrame's some first rows |
| 53 | """ |
| 54 | return self._jddf.getViewHandler().head(n) |
| 55 | |
| 56 | def project(self, column_names): |
| 57 | """ |
| 58 | Project on some columns and return a new DistributedDataFrame |
| 59 | """ |
| 60 | return DistributedDataFrame(self._jddf.getViewHandler().project(column_names)) |
| 61 | |
| 62 | def sample(self, size, replacement=False, seed=123): |
| 63 | """ |
| 64 | Get a sample of this DistributedDataFrame and return a list of strings |
| 65 |
no outgoing calls
no test coverage detected