question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: to_clipboard(as="html" | "markdown" | "latex" | ...)

See original GitHub issue

Is your feature request related to a problem?

When writing papers, it’s often useful to be able to copy dataframes into documents as Markdown, HTML or LaTeX.

Describe the solution you’d like

Allow more formats besides excel: bool in DataFrame.to_clipboard(). For example, a new keyword as:

df.to_clipboard(as="html" | "markdown" | "latex" | ...)

API breaking implications

Pure extension unless excel keyword of to_clipboard() was removed in favor of as.

Describe alternatives you’ve considered

The other option would be allowing the buf argument of df.to_(html|markdown|latex|...) to take the string "clipboard":

df.to_markdown(buf="clipboard")

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
attack68commented, Mar 9, 2022

clipboard_set is used within DataFrame.to_clipboard.

I would hazard that to_clipboard might have been coded before the other formats, html, laTex etc became available. It seems to be a simple extension to change excel={True, False} to something like format={"excel", "str", "html", "latex"} and to call the relevant renderer.

1reaction
wany-ohcommented, Mar 9, 2022

It seems that clipboard_set() can be used.

import pandas as pd
from pandas.io.clipboard import clipboard_set

df = pd._testing.makeMixedDataFrame()

clipboard_set(df.to_html())
clipboard_set(df.to_latex())
clipboard_set(df.to_markdown())
...
clipboard_set(str(df))  # It can copy anything of type str
Read more comments on GitHub >

github_iconTop Results From Across the Web

Copy URL To Clipboard - Firefox Browser Add-ons - Mozilla
Copy document URL / link URL to clipboard as HTML, Markdown, BBCode, Textile, AsciiDoc, MediaWiki, Jira, reStructuredText, LaTeX, Text. You'll need Firefox to ......
Read more >
Copy Webpage Content as HTML, Markdown, BBCode, Plain ...
Here is a free Chrome extension to copy webpage content as HTML, Markdown, BBCode formatting, plain text, etc. This extension is named as ......
Read more >
How can I mix LaTeX in with Markdown? - Stack Overflow
But this term I'm teaching a class with a lot of math, and I'd love to be able to put LaTeX formulas with...
Read more >
Spell Right - Visual Studio Marketplace
Spells plain text/markdown/LaTeX documents, comments/strings parts of ... (e.g. strings spelled in English and comments spelled in French).
Read more >
Markdown syntax for wikis - Azure DevOps | Microsoft Learn
In this article, find some wiki-specific Markdown syntax guidance for ... Pasting rich content as HTML is supported in Azure DevOps Server ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found