Skip to content

Commit e46d5ac

Browse files
committed
code formatting in docs
1 parent 520f9c5 commit e46d5ac

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

doc/source/whatsnew/v1.1.0.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ representation of :class:`DataFrame` objects (:issue:`4889`).
285285
286286
df = pd.DataFrame.from_records(
287287
[[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"]),
288+
index=pd.MultiIndex.from_tuples([("a", "b"), ("a", "c")],
289+
names=["n1", "n2"]),
290+
columns=pd.MultiIndex.from_tuples([("x", 1), ("y", 2)],
291+
names=["z1", "z2"]),
290292
)
291293
df
292294
df.to_dict(orient='tight')

pandas/core/frame.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,15 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> "DataFra
12861286
row_1 3 2 1 0
12871287
row_2 a b c d
12881288
1289+
When using the 'index' orientation, the column names can be
1290+
specified manually:
1291+
1292+
>>> pd.DataFrame.from_dict(data, orient='index',
1293+
... columns=['A', 'B', 'C', 'D'])
1294+
A B C D
1295+
row_1 3 2 1 0
1296+
row_2 a b c d
1297+
12891298
Specify ``orient='tight'`` to create the DataFrame using a 'tight'
12901299
format.
12911300
>>> data = {'index': [('a', 'b'), ('a', 'c')],
@@ -1299,15 +1308,6 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> "DataFra
12991308
n1 n2
13001309
a b 1 3
13011310
c 2 4
1302-
1303-
When using the 'index' orientation, the column names can be
1304-
specified manually:
1305-
1306-
>>> pd.DataFrame.from_dict(data, orient='index',
1307-
... columns=['A', 'B', 'C', 'D'])
1308-
A B C D
1309-
row_1 3 2 1 0
1310-
row_2 a b c d
13111311
"""
13121312
index = None
13131313
orient = orient.lower()

0 commit comments

Comments
 (0)