Series#
Each column in a Table is a Series. Series expose methods which invoke high-performance kernels for manipulation of a column of data.
Series #
Series()
A Daft Series is an array of data of a single type, and is usually a column in a DataFrame.
Methods:
Name | Description |
---|---|
from_arrow | Construct a Series from an pyarrow array or chunked array. |
from_numpy | Construct a Series from a NumPy ndarray. |
from_pandas | Construct a Series from a pandas Series. |
from_pylist | Construct a Series from a Python list. |
to_arrow | Convert this Series to an pyarrow array. |
to_pylist | Convert this Series to a Python list. |
Source code in daft/series.py
55 56 |
|
from_arrow #
from_arrow(
array: Array | ChunkedArray, name: str = "arrow_series"
) -> Series
Construct a Series from an pyarrow array or chunked array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array | Array | ChunkedArray | The pyarrow (chunked) array whose data we wish to put in the Series. | required |
name | str | The name associated with the Series; this is usually the column name. | 'arrow_series' |
Source code in daft/series.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
from_numpy #
from_numpy(
data: ndarray[Any, Any], name: str = "numpy_series"
) -> Series
Construct a Series from a NumPy ndarray.
If the provided NumPy ndarray is 1-dimensional, Daft will attempt to store the ndarray in a pyarrow Array. If the ndarray has more than 1 dimension OR storing the 1D array in Arrow failed, Daft will store the ndarray data as a Python list of NumPy ndarrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | ndarray[Any, Any] | The NumPy ndarray whose data we wish to put in the Series. | required |
name | str | The name associated with the Series; this is usually the column name. | 'numpy_series' |
Source code in daft/series.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
from_pandas #
from_pandas(
data: Series[Any], name: str = "pd_series"
) -> Series
Construct a Series from a pandas Series.
This will first try to convert the series into a pyarrow array, then will fall back to converting the series to a NumPy ndarray and going through that construction path, and will finally fall back to converting the series to a Python list and going through that path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | Series[Any] | The pandas Series whose data we wish to put in the Daft Series. | required |
name | str | The name associated with the Series; this is usually the column name. | 'pd_series' |
Source code in daft/series.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
from_pylist #
from_pylist(
data: list[Any],
name: str = "list_series",
pyobj: Literal["allow", "disallow", "force"] = "allow",
) -> Series
Construct a Series from a Python list.
The resulting type depends on the setting of pyobjects
"allow"
: Arrow-backed types if possible, else PyObject;"disallow"
: Arrow-backed types only, raising error if not convertible;"force"
: Store as PyObject types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | list[Any] | The Python list whose data we wish to put in the Series. | required |
name | str | The name associated with the Series; this is usually the column name. | 'list_series' |
pyobj | Literal['allow', 'disallow', 'force'] | Whether we want to | 'allow' |
Source code in daft/series.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
to_arrow #
to_arrow() -> Array
Convert this Series to an pyarrow array.
Source code in daft/series.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
to_pylist #
to_pylist() -> list[Any]
Convert this Series to a Python list.
Source code in daft/series.py
274 275 276 277 278 279 280 281 |
|