Skip to content

Commit ad7dc7a

Browse files
mroeschkenoatamir
authored andcommitted
DOC: Add missing API item to reference docs (pandas-dev#48455)
* DOC: Add missing API item to reference docs * Address review * Fix formatting
1 parent b973c7d commit ad7dc7a

File tree

6 files changed

+141
-20
lines changed

6 files changed

+141
-20
lines changed

doc/source/reference/arrays.rst

+52-16
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ objects contained with a :class:`Index`, :class:`Series`, or
1919
For some data types, pandas extends NumPy's type system. String aliases for these types
2020
can be found at :ref:`basics.dtypes`.
2121

22-
=================== ========================= ============================= =============================
23-
Kind of Data pandas Data Type Scalar Array
24-
=================== ========================= ============================= =============================
25-
TZ-aware datetime :class:`DatetimeTZDtype` :class:`Timestamp` :ref:`api.arrays.datetime`
26-
Timedeltas (none) :class:`Timedelta` :ref:`api.arrays.timedelta`
27-
Period (time spans) :class:`PeriodDtype` :class:`Period` :ref:`api.arrays.period`
28-
Intervals :class:`IntervalDtype` :class:`Interval` :ref:`api.arrays.interval`
29-
Nullable Integer :class:`Int64Dtype`, ... (none) :ref:`api.arrays.integer_na`
30-
Categorical :class:`CategoricalDtype` (none) :ref:`api.arrays.categorical`
31-
Sparse :class:`SparseDtype` (none) :ref:`api.arrays.sparse`
32-
Strings :class:`StringDtype` :class:`str` :ref:`api.arrays.string`
33-
Boolean (with NA) :class:`BooleanDtype` :class:`bool` :ref:`api.arrays.bool`
34-
PyArrow :class:`ArrowDtype` Python Scalars or :class:`NA` :ref:`api.arrays.arrow`
35-
=================== ========================= ============================= =============================
22+
=================== ========================== ============================= =============================
23+
Kind of Data pandas Data Type Scalar Array
24+
=================== ========================== ============================= =============================
25+
TZ-aware datetime :class:`DatetimeTZDtype` :class:`Timestamp` :ref:`api.arrays.datetime`
26+
Timedeltas (none) :class:`Timedelta` :ref:`api.arrays.timedelta`
27+
Period (time spans) :class:`PeriodDtype` :class:`Period` :ref:`api.arrays.period`
28+
Intervals :class:`IntervalDtype` :class:`Interval` :ref:`api.arrays.interval`
29+
Nullable Integer :class:`Int64Dtype`, ... (none) :ref:`api.arrays.integer_na`
30+
Nullable Float :class:`Float64Dtype`, ... (none) :ref:`api.arrays.float_na`
31+
Categorical :class:`CategoricalDtype` (none) :ref:`api.arrays.categorical`
32+
Sparse :class:`SparseDtype` (none) :ref:`api.arrays.sparse`
33+
Strings :class:`StringDtype` :class:`str` :ref:`api.arrays.string`
34+
Nullable Boolean :class:`BooleanDtype` :class:`bool` :ref:`api.arrays.bool`
35+
PyArrow :class:`ArrowDtype` Python Scalars or :class:`NA` :ref:`api.arrays.arrow`
36+
=================== ========================== ============================= =============================
3637

3738
pandas and third-party libraries can extend NumPy's type system (see :ref:`extending.extension-types`).
3839
The top-level :meth:`array` method can be used to create a new array, which may be
@@ -91,13 +92,20 @@ with the :class:`arrays.DatetimeArray` extension array, which can hold timezone-
9192
or timezone-aware values.
9293

9394
:class:`Timestamp`, a subclass of :class:`datetime.datetime`, is pandas'
94-
scalar type for timezone-naive or timezone-aware datetime data.
95+
scalar type for timezone-naive or timezone-aware datetime data. :class:`NaT`
96+
is the missing value for datetime data.
9597

9698
.. autosummary::
9799
:toctree: api/
98100

99101
Timestamp
100102

103+
.. autosummary::
104+
:toctree: api/
105+
:template: autosummary/class_without_autosummary.rst
106+
107+
NaT
108+
101109
Properties
102110
~~~~~~~~~~
103111
.. autosummary::
@@ -208,13 +216,20 @@ Timedeltas
208216
----------
209217

210218
NumPy can natively represent timedeltas. pandas provides :class:`Timedelta`
211-
for symmetry with :class:`Timestamp`.
219+
for symmetry with :class:`Timestamp`. :class:`NaT`
220+
is the missing value for timedelta data.
212221

213222
.. autosummary::
214223
:toctree: api/
215224

216225
Timedelta
217226

227+
.. autosummary::
228+
:toctree: api/
229+
:template: autosummary/class_without_autosummary.rst
230+
231+
NaT
232+
218233
Properties
219234
~~~~~~~~~~
220235
.. autosummary::
@@ -419,6 +434,26 @@ pandas provides this through :class:`arrays.IntegerArray`.
419434
UInt16Dtype
420435
UInt32Dtype
421436
UInt64Dtype
437+
NA
438+
439+
.. _api.arrays.float_na:
440+
441+
Nullable float
442+
--------------
443+
444+
.. autosummary::
445+
:toctree: api/
446+
:template: autosummary/class_without_autosummary.rst
447+
448+
arrays.FloatingArray
449+
450+
.. autosummary::
451+
:toctree: api/
452+
:template: autosummary/class_without_autosummary.rst
453+
454+
Float32Dtype
455+
Float64Dtype
456+
NA
422457

423458
.. _api.arrays.categorical:
424459

@@ -555,6 +590,7 @@ with a bool :class:`numpy.ndarray`.
555590
:template: autosummary/class_without_autosummary.rst
556591

557592
BooleanDtype
593+
NA
558594

559595

560596
.. Dtype attributes which are manually listed in their docstrings: including

doc/source/reference/general_functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Data manipulations
2626
from_dummies
2727
factorize
2828
unique
29+
lreshape
2930
wide_to_long
3031

3132
Top-level missing data

doc/source/reference/groupby.rst

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ Indexing, iteration
2727

2828
Grouper
2929

30+
Function application helper
31+
---------------------------
32+
.. autosummary::
33+
:toctree: api/
34+
35+
NamedAgg
36+
3037
.. currentmodule:: pandas.core.groupby
3138

3239
Function application

doc/source/reference/options.rst

+7
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ Working with options
1919
get_option
2020
set_option
2121
option_context
22+
23+
Numeric formatting
24+
------------------
25+
.. autosummary::
26+
:toctree: api/
27+
28+
set_eng_float_format

pandas/core/groupby/generic.py

+25
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@
115115

116116

117117
class NamedAgg(NamedTuple):
118+
"""
119+
Helper for column specific aggregation with control over output column names.
120+
121+
Subclass of typing.NamedTuple.
122+
123+
Parameters
124+
----------
125+
column : Hashable
126+
Column label in the DataFrame to apply aggfunc.
127+
aggfunc : function or str
128+
Function to apply to the provided column. If string, the name of a built-in
129+
pandas function.
130+
131+
Examples
132+
--------
133+
>>> df = pd.DataFrame({"key": [1, 1, 2], "a": [-1, 0, 1], 1: [10, 11, 12]})
134+
>>> agg_a = pd.NamedAgg(column="a", aggfunc="min")
135+
>>> agg_1 = pd.NamedAgg(column=1, aggfunc=np.mean)
136+
>>> df.groupby("key").agg(result_a=agg_a, result_1=agg_1)
137+
result_a result_1
138+
key
139+
1 -1 10.5
140+
2 1 12.0
141+
"""
142+
118143
column: Hashable
119144
aggfunc: AggScalar
120145

pandas/io/formats/format.py

+49-4
Original file line numberDiff line numberDiff line change
@@ -2116,11 +2116,56 @@ def __call__(self, num: float) -> str:
21162116

21172117
def set_eng_float_format(accuracy: int = 3, use_eng_prefix: bool = False) -> None:
21182118
"""
2119-
Alter default behavior on how float is formatted in DataFrame.
2120-
Format float in engineering format. By accuracy, we mean the number of
2121-
decimal digits after the floating point.
2119+
Format float representation in DataFrame with SI notation.
21222120
2123-
See also EngFormatter.
2121+
Parameters
2122+
----------
2123+
accuracy : int, default 3
2124+
Number of decimal digits after the floating point.
2125+
use_eng_prefix : bool, default False
2126+
Whether to represent a value with SI prefixes.
2127+
2128+
Returns
2129+
-------
2130+
None
2131+
2132+
Examples
2133+
--------
2134+
>>> df = pd.DataFrame([1e-9, 1e-3, 1, 1e3, 1e6])
2135+
>>> df
2136+
0
2137+
0 1.000000e-09
2138+
1 1.000000e-03
2139+
2 1.000000e+00
2140+
3 1.000000e+03
2141+
4 1.000000e+06
2142+
2143+
>>> pd.set_eng_float_format(accuracy=1)
2144+
>>> df
2145+
0
2146+
0 1.0E-09
2147+
1 1.0E-03
2148+
2 1.0E+00
2149+
3 1.0E+03
2150+
4 1.0E+06
2151+
2152+
>>> pd.set_eng_float_format(use_eng_prefix=True)
2153+
>>> df
2154+
0
2155+
0 1.000n
2156+
1 1.000m
2157+
2 1.000
2158+
3 1.000k
2159+
4 1.000M
2160+
2161+
>>> pd.set_eng_float_format(accuracy=1, use_eng_prefix=True)
2162+
>>> df
2163+
0
2164+
0 1.0n
2165+
1 1.0m
2166+
2 1.0
2167+
3 1.0k
2168+
4 1.0M
21242169
"""
21252170
set_option("display.float_format", EngFormatter(accuracy, use_eng_prefix))
21262171

0 commit comments

Comments
 (0)