Skip to content

Commit 520f9c5

Browse files
committed
fix up documentation formatting
1 parent bed9772 commit 520f9c5

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

doc/source/whatsnew/v1.1.0.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,17 @@ DataFrame.from_dict and DataFrame.to_dict have new ``'tight'`` option
277277
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
278278

279279
A new ``'tight'`` dictionary format that preserves :class:`MultiIndex` entries and names
280-
is now available, and can be used with the standard `json` library to produce a tight
280+
is now available with the :meth:`DataFrame.from_dict` and :meth:`DataFrame.to_dict` methods
281+
and can be used with the standard ``json`` library to produce a tight
281282
representation of :class:`DataFrame` objects (:issue:`4889`).
282283

283284
.. ipython:: python
284285
285-
df = pd.DataFrame.from_records([[1, 3], [2, 4]],
286-
index=pd.MultiIndex.from_tuples([("a", "b"), ("a", "c")], names=["n1", "n2"]),
287-
columns=pd.MultiIndex.from_tuples([("x", 1), ("y", 2)], names=["z1", "z2"]))
286+
df = pd.DataFrame.from_records(
287+
[[1, 3], [2, 4]],
288+
index=pd.MultiIndex.from_tuples([("a", "b"), ("a", "c")], names=["n1", "n2"]),
289+
columns=pd.MultiIndex.from_tuples([("x", 1), ("y", 2)], names=["z1", "z2"]),
290+
)
288291
df
289292
df.to_dict(orient='tight')
290293

pandas/core/frame.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,8 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> "DataFra
12431243
If 'tight', assume a dict with keys ['index', 'columns', 'data',
12441244
'index_names', 'column_names']
12451245
1246-
.. versionadded:: 1.1.0
1247-
'tight' as an allowed value for the ``orient`` argument
1246+
.. versionadded:: 1.1.0
1247+
'tight' as an allowed value for the ``orient`` argument
12481248
12491249
dtype : dtype, default None
12501250
Data type to force, otherwise infer.
@@ -1289,10 +1289,10 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> "DataFra
12891289
Specify ``orient='tight'`` to create the DataFrame using a 'tight'
12901290
format.
12911291
>>> data = {'index': [('a', 'b'), ('a', 'c')],
1292-
'columns': [('x', 1), ('y', 2)],
1293-
'data': [[1, 3], [2, 4]],
1294-
'index_names': ['n1', 'n2'],
1295-
'column_names': ['z1', 'z2']}
1292+
... 'columns': [('x', 1), ('y', 2)],
1293+
... 'data': [[1, 3], [2, 4]],
1294+
... 'index_names': ['n1', 'n2'],
1295+
... 'column_names': ['z1', 'z2']}
12961296
>>> pd.DataFrame.from_dict(data, orient='tight')
12971297
z1 x y
12981298
z2 1 2
@@ -1433,8 +1433,8 @@ def to_dict(self, orient="dict", into=dict):
14331433
Abbreviations are allowed. `s` indicates `series` and `sp`
14341434
indicates `split`.
14351435
1436-
.. versionadded:: 1.1.0
1437-
'tight' as an allowed value for the ``orient`` argument
1436+
.. versionadded:: 1.1.0
1437+
'tight' as an allowed value for the ``orient`` argument
14381438
14391439
into : class, default dict
14401440
The collections.abc.Mapping subclass used for all Mappings

0 commit comments

Comments
 (0)