Skip to content

Commit

Permalink
Merge pull request #234 from ilya112358/update_readme_headers_dicts
Browse files Browse the repository at this point in the history
Fix #207. Update README: headers for dictionaries.
  • Loading branch information
astanin authored Sep 26, 2024
2 parents 12a805b + 72ac2ab commit 2f3a737
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,22 @@ dictionaries or named tuples:
```pycon
>>> print(tabulate({"Name": ["Alice", "Bob"],
... "Age": [24, 19]}, headers="keys"))
Age Name
----- ------
24 Alice
19 Bob
Name Age
------ -----
Alice 24
Bob 19
```

When data is a list of dictionaries, a dictionary can be passed as `headers`
to replace the keys with other column labels:

```pycon
>>> print(tabulate([{1: "Alice", 2: 24}, {1: "Bob", 2: 19}],
... headers={1: "Name", 2: "Age"}))
Name Age
------ -----
Alice 24
Bob 19
```

### Row Indices
Expand Down

0 comments on commit 2f3a737

Please sign in to comment.