Skip to content
Advertisement

Is there the equivalent of to_markdown to read data?

With pandas 1.0.0 the use of .to_markdown() to show the content of a dataframe in this forum in markdown is going to proliferate. Is there a convenient way to load the data back into a dataframe? Maybe an option to .from_clipboard(markdown=True)?

Advertisement

Answer

None of the answers so far read the data from the clipboard. They all require the data to be in a string. This led me to look into the source code of pandas.read_clipboard(), and lo and behold, the method internally uses pandas.read_csv(), and passes all arguments to it. This automatically leads to the following solution:

JavaScript
JavaScript

Mark the table and copy it to the clipboard (Ctrl-C on Windows). Building on the above answers:

JavaScript

The next step would be to integrate this into https://pyjanitor-devs.github.io/pyjanitor/ so it can be easily called with a markdown=True parameter.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement