This article was also cross posted to dev.to feel free to drop in to give it a ♥ and leave comment.
I commonly have a need to paste the first few lines of a dataset into a markdown file. I use two handy packages to do this,
pyperclip. Lets say I have a Pandas DataFrame in memory as
df already. All I would need to do to convert the first 5 rows to markdown and copy it to the clipboard is the following.
from tabulate import tabulate import pyperclip md = tabulate.tabulate(df.head(), df.columns, tablefmt='pipe') pyperclip.copy(md)
This is a super handy snippet that I use a lot. Folks really appreciate it when they can see a sample of the data without opening the entire file.
👀 see an issue, edit this post on GitHub
If you found value in this post
and want to send a tip.
Check out my otherblogs
I write short articles about developing a successful mindset for the tech industry once or so per week.Subscribe
Someday I hope to announce courses/side projects there as well.
Unsubscribe at any time