Skip to content

Commit 72ac2ab

Browse files
authored
Fix #207. Update README: headers for dictionaries.
1 parent 83fd4fb commit 72ac2ab

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,22 @@ dictionaries or named tuples:
121121
```pycon
122122
>>> print(tabulate({"Name": ["Alice", "Bob"],
123123
... "Age": [24, 19]}, headers="keys"))
124-
Age Name
125-
----- ------
126-
24 Alice
127-
19 Bob
124+
Name Age
125+
------ -----
126+
Alice 24
127+
Bob 19
128+
```
129+
130+
When data is a list of dictionaries, a dictionary can be passed as `headers`
131+
to replace the keys with other column labels:
132+
133+
```pycon
134+
>>> print(tabulate([{1: "Alice", 2: 24}, {1: "Bob", 2: 19}],
135+
... headers={1: "Name", 2: "Age"}))
136+
Name Age
137+
------ -----
138+
Alice 24
139+
Bob 19
128140
```
129141

130142
### Row Indices

0 commit comments

Comments
 (0)