I'm facing a strange behavior with Google colab and pandas style. When applying a style to a dataframe on google colab, some of the basic styling is messed up: the table becomes smaller and more condensed, the highlight of every other row disappears, and the hover highlight of rows stops working.
I'm attaching a side-by-side picture of two screenshots: one from a regular Jupiter notebook, in which things are working fine, and another one from Google colab - in which styling messes up things.
The code is extremely simple:
df = pd.DataFrame(range(5)) # create a data frame
df # in a new cell - just show the dataframe
df.style.highlight_max() # again, in a new cell. Works in Jupyter notebook,
# doesn't work well on Google Colab.
Any help would be appreciated.
As I understand in Google Colab environment pandas is pre-installed. However the version it use it's not the recent one. It is still use the 0.22.
Note: The imshow method of cv2 is disabled in Google Colab. Thus, colab users need to import cv2_imshow for displaying images. So the commands will be like: Jupyter Notebook: cv2.
However, pandas_profiling cannot be straightforwardly used on Colab. The code will result in an error, as below; This is because Google Colab comes with a pre-installed older version of Pandas-profiling (v1) and the join_axes function is deprecated in the installed Pandas version on Google Colab.
This is because Google Colab comes with a pre-installed older version of Pandas-profiling (v1) and the join_axes function is deprecated in the installed Pandas version on Google Colab. STEPS : Install Pandas Profiling on Google Colab. 1. Run the below command, you can visit the link on github.
However, profile.to_widgets () will not be working properly as it is not yet fully supported on Google Colab, as below snapshot : 7. Instead, change to profile.to_notebook_iframe (), as below snapshot: 8. Save your output file in html format: so you can share as a webpage
There's no way to run the colab frontend locally. To note, however, that Colaboratory lets you connect to a local runtime using Jupyter. This allows you to execute code on your local hardware and have access to your local file system (it's a Colab frontend with a local runtime). If that is your goal, here you can find a way to do that.
I don't think this is pandas styler. All pandas does is render HTML which works well in Notebook or normal browsers. (Jupyter has its own set of CSS that it applies to rendered tables). Google colab will have their own set of CSS.
I suspect the hierarchy of colab's default CSS is not as dominant as Jupyters. Maybe file an issue with them?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With