With the help of pandas.to_markdown() method, we can get the markdown table from the given dataframes by using pandas.to_markdown() method.
Syntax :
pandas.to_markdown()Return : Return the markdown table.
Example #1 :
In this example we can see that by using pandas.to_markdown() method, we are able to get the markdown table from the given dataframes by using this method.
# import pandas import pandas as pd df = pd.DataFrame({"A": [1, 2, 3], "B": [1.1, 2.2, 3.3]}, index =['a', 'a', 'b']) # Using pandas.to_markdown() method gfg = df.to_markdown() print(gfg) |
Output :
| | A | B | |:---|----:|----:| | a | 1 | 1.1 | | a | 2 | 2.2 | | b | 3 | 3.3 |
Example #2 :
# import pandas import pandas as pd df = pd.DataFrame({"A": [3, 4, 5], "B": ['c', 'd', 'e']}, index =['I', 'II', 'III']) # Using pandas.to_markdown() method gfg = df.to_markdown() print(gfg) |
Output :
| | A | B | |:----|----:|:----| | I | 3 | c | | II | 4 | d | | III | 5 | e |
Recommended Posts:
- Add a Pandas series to another Pandas series
- Python | Pandas Index.insert()
- Python | Pandas DatetimeIndex.inferred_freq
- Python | Pandas PeriodIndex.start_time
- Python | Pandas PeriodIndex.week
- Python | Pandas Timestamp.second
- Python | Pandas Series.asobject
- Python | Pandas str.join() to join string/list elements with passed delimiter
- Python | Pandas DataFrame.reset_index()
- Python | Pandas dataframe.notna()
- Python | Pandas PeriodIndex.weekday
- Python | Pandas Series.dt.floor
- Python | Pandas Index.get_slice_bound()
- Python | Pandas Dataframe.duplicated()
- Python | Pandas dataframe.notnull()
- Python | Pandas series.cumprod() to find Cumulative product of a Series
- Use Pandas to Calculate Statistics in Python
- Python | Pandas Timestamp.date
- Python | Pandas Timestamp.ctime
- Python | Pandas dataframe.round()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

