Skip to content

Commit 997f502

Browse files
xhochywesm
authored andcommitted
ARROW-382: Extend Python API documentation
* Fix numpydoc compilation * Add simple examples to the API * Move away from deprecated Cython-property declaration * Add basic descriptions with return types to functions Author: Uwe L. Korn <uwelk@xhochy.com> Closes #208 from xhochy/ARROW-382 and squashes the following commits: 31e0cb3 [Uwe L. Korn] ARROW-382: Extend Python API documentation
1 parent ed6ec3b commit 997f502

File tree

4 files changed

+318
-75
lines changed

4 files changed

+318
-75
lines changed

python/doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@
5959
'sphinx.ext.doctest',
6060
'sphinx.ext.mathjax',
6161
'sphinx.ext.viewcode',
62-
'numpydoc'
62+
'sphinx.ext.napoleon'
6363
]
6464

65+
# numpydoc configuration
66+
napoleon_use_rtype = False
67+
6568
# Add any paths that contain templates here, relative to this directory.
6669
templates_path = ['_templates']
6770

python/pyarrow/array.pyx

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,41 @@ cdef class Array:
5454

5555
@staticmethod
5656
def from_pandas(obj, mask=None):
57+
"""
58+
Create an array from a pandas.Series
59+
60+
Parameters
61+
----------
62+
obj : pandas.Series or numpy.ndarray
63+
vector holding the data
64+
mask : numpy.ndarray, optional
65+
boolean mask if the object is valid or null
66+
67+
Returns
68+
-------
69+
pyarrow.Array
70+
71+
Examples
72+
--------
73+
74+
>>> import pandas as pd
75+
>>> import pyarrow as pa
76+
>>> pa.Array.from_pandas(pd.Series([1, 2]))
77+
<pyarrow.array.Int64Array object at 0x7f674e4c0e10>
78+
[
79+
1,
80+
2
81+
]
82+
83+
84+
>>> import numpy as np
85+
>>> pa.Array.from_pandas(pd.Series([1, 2]), np.array([0, 1], dtype=bool))
86+
<pyarrow.array.Int64Array object at 0x7f9019e11208>
87+
[
88+
1,
89+
NA
90+
]
91+
"""
5792
return from_pandas_series(obj, mask)
5893

5994
property null_count:
@@ -228,6 +263,14 @@ cdef object box_arrow_array(const shared_ptr[CArray]& sp_array):
228263
def from_pylist(object list_obj, DataType type=None):
229264
"""
230265
Convert Python list to Arrow array
266+
267+
Parameters
268+
----------
269+
list_obj : array_like
270+
271+
Returns
272+
-------
273+
pyarrow.array.Array
231274
"""
232275
cdef:
233276
shared_ptr[CArray] sp_array
@@ -246,15 +289,19 @@ def from_pandas_series(object series, object mask=None, timestamps_to_ms=False):
246289
247290
Parameters
248291
----------
249-
series: pandas.Series or numpy.ndarray
292+
series : pandas.Series or numpy.ndarray
250293
251-
mask: pandas.Series or numpy.ndarray
294+
mask : pandas.Series or numpy.ndarray, optional
252295
array to mask null entries in the series
253296
254-
timestamps_to_ms: bool
297+
timestamps_to_ms : bool, optional
255298
Convert datetime columns to ms resolution. This is needed for
256299
compability with other functionality like Parquet I/O which
257300
only supports milliseconds.
301+
302+
Returns
303+
-------
304+
pyarrow.array.Array
258305
"""
259306
cdef:
260307
shared_ptr[CArray] out

python/pyarrow/compat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@ def frombytes(o):
9090

9191

9292
integer_types = six.integer_types + (np.integer,)
93+
94+
__all__ = []

0 commit comments

Comments
 (0)