Skip to content

dwisdom0/pandas-image-format

Repository files navigation

This one weird trick makes plt.imshow() irrelevant!!!1!!1!!

Never import matplotlib again!

. . .
mona_lisa_df = pd.DataFrame.from_records(hex_mona_lisa)
show_img(mona_lisa_df.style, pixel_size=8)

Mona Lisa

What?

Pandas has some formatting tools that are a little bit like Excel's "Conditional Formatting" feature. I used those formatting tools to color each cell to match the hex string in the cell. For example, a cell with the value #639 would show up as a single pixel colored rebeccapurple (get a box of tissues ready before you click that link).

Et voilà.

Binder

You have to run all the cells to get the images to show up. The easiest way to do that is to hit the button at the top that looks like a fast-forward button. It should say "Restart Kernel and Run All Cells" when you hover over it.

About

Pandas DataFrames are secretly an image format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published