This is a feature request to add an optional index=False argument to the new to_markdown() dataframe method. This would produce a markdown table without the initial unnamed index column.
This is actually possible by passing showindex=False, but could probably be better documented (it's one of the tabulate kwargs):
In [1]: import pandas as pd
In [2]: df = pd.DataFrame({"a": [1, 2, 3]})
In [3]: print(df.to_markdown(showindex=False))
| a |
|----:|
| 1 |
| 2 |
| 3 |
TBH I'm not sure it's worth documenting tabulate-specific kwargs, but adding an example showing the behaviour of df.to_markdown(showindex=False) would be nice.
@chrisjcameron are you interested in submitting a PR? If so, see the contributing guide for how to get started
adding index=False here would be ok (and translating to tabulate)
PR welcome
take
What should the behaviour be if user set both showindex and index? Which one should take the priority or should I raise an ValueError
Does it make sense to add the index parameter if the showindex parameter already exists and will be used in the same way?
I can submit PR with added examples
It would be more consistent with the other pandas to_* methods if the parameter to control including the index was called index rather than showindex.
What should the behaviour be if user set both
showindexandindex? Which one should take the priority or should I raise anValueError
I think most users will be expecting pandas-like keywords to work, so I would prioritize those. An alternative might be a warning about "When both index and showindex are set, one value will be used but which is undefined". This would at least give users a clue that these need not both be specified but gives a lot of latitude for future refinement that changes the behavior.
thumbs up for this enhancement to the docs. l landed here looking exactly for that https://github.com/pandas-dev/pandas/blob/3adf3340453d6704d4a2cb47058214cc697a7d29/pandas/core/frame.py#L1996-L2024
Most helpful comment
This is actually possible by passing
showindex=False, but could probably be better documented (it's one of thetabulatekwargs):