I have a Pandas Dataframe generated from a database, which has data with mixed encodings. For example:
+----+-------------------------+----------+-----------
Pandas 1.0 was released 29 january 2020 and supports markdown conversion, so you can now do this directly!
Example taken from the docs:
df = pd.DataFrame({"A": [1, 2, 3], "B": [1, 2, 3]}, index=['a', 'a', 'b'])
print(df.to_markdown())
| | A | B |
|:---|----:|----:|
| a | 1 | 1 |
| a | 2 | 2 |
| b | 3 | 3 |
Or without the index:
print(df.to_markdown(index=False)) # use 'showindex' for pandas < 1.1
| A | B |
|----:|----:|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |