How to increase the font size/ better render Pandas dataframes in Jupyter Notebooks opened in VS Code? - pandas

Is there a way to change how Pandas dataframes are rendered in output cells of Jupyter Notebooks opened in VS Code? By default, the font of the dataframe output is small, regardless of my VS code settings (see 1). In addition, I'd like for the dateframes to render more like the default rendering in native Jupyter notebook opened in a browser (see 2). Does anyone know how to make VS code change the dataframe rendering. Is there something I need to change in settings?
Notebook in VS Code:
Notebook in Chrome:
Edit: Using print(df) only increases the font size to match my font settings, but doesn't change the appearance.

Maybe these two new settings in vscode v1.67 will help:
notebook.outputFontSize, "Font size for plain text outputs. When set to 0 #editor.fontSize# is used."
notebook.outputFontFamily, "The font family for plain text output of notebook cells. When set to empty, the #editor.fontFamily# is used."
from https://github.com/microsoft/vscode/pull/147321/commits/51ab78f535d8537e031e1ae77cac678ae22b0249

Related

Display dataframe in a separate panel in Jupyter Lab

I would like to display my dataframe in a seperate panel/window in Jupyter Lab. Currently, I can open .csv files in a separate window (which helps write code side-by-side to the data I'm working with), but I want to do this with active dataframes as well.
Is there a way to do this native to Jupyterlab, similar to how it is done in MATLAB? If not, what is the best way to do it otherwise?
Yes. There are several ways:
Display the data frame in a cell output, then right-click on the output and select Create New View for Output
Use jupyterlab-sidecar package:
from sidecar import Sidecar
sc = Sidecar(title='My dataframe')
with sc:
display(df)
(JupyterLab 3.3+) Activate the visual debugger, go to variables list, hover over the variable and click on loop icon.
You can combine approach (1) or (2) with IPython widgets to create an interactive explorer for larger data frames, such as this pandas_explorer snippet. There are other, more complete, interactive explorers which you can embed in a sidecar or move to the new output, for example ipydatagrid.

Matplotlib plots on VS Code jupyter notebook takes all the width

Plot on VS Code jupyter notebook takes all the width on cell output. Before June update this wasn't a problem. Problem is on dark theme it creates too much unnecessary white space. Does anyone know the reason?
you can "fix" it for your current notebook session by resetting matplotlib option back to default .
import matplotlib as mpl
mpl.rcParams.update(mpl.rcParamsDefault)
If you check on the vs code notebook docs, you can see the same white space appears in their screenshots.

Formatting of pandas dataframes in Jupyter Notebook

When I display a pandas dataframe in a Jupyter Notebook using, e.g. df.head(), I get a display with all white columns. However, on some websites I have seen them formatted with an alternating white and gray rows here. Is this possible inside the notebook?
This is a recent change in Jupyter's default table styling. I saw this change in my own notebooks when I upgraded Jupyter.

How to make nice pdf out of jupyter file?

I am supposed to create pdf documents that contain math expression and graph images.
Until now my work flow was using matlab to draw the plots, export them into jpg, put them into OpenOffice / Word document describe how I get those plots trough math equations and finally export to pdf.
Recently I have found julia ( replacement for matlab ) and jupyter ( replacement for Word ).
Jupyter is awesome but the export to PDF is lacking some features :
Hide code cell. ( I don't want to show the code I used to generate those graphs. )
Hide output of code cell. ( I don't want to show output of using Plots; plotlyjs() )
Hide the IN [...] and OUT [...] annotations.
Increase space size between lines.
I hope there is some easy way to do this. Otherwise I will have to go back to Word and Matlab.
Thank you!
You might want to consider investing some time learning how to use the nbconvert tool that comes with jupyter notebook. It supports multiple output formats including PDF and also supports custom templates. For example see this older post for an example of hiding code input and only showing output.

How to change colors of function plots in Tensorboard?

I'm trying to compare different learning-rate-decays using Tensorflow. Therefore I visualize the cost functions in Tensorboard ('EVENTS'-tab). My problem is that the different plots of the functions are in very similar colors making it hard to compare them. Is there any possibility to change those colors?
Just create different summary writes with different log files for each learning rate. Then launch the tensorboard tool using:
tensorboard --logdir=tag1:/path/to/summary/one,tag2:/path/to/summary/two
There's currently no way to change those colors, but a recent release has made the colors more differentiated. Try updating and seeing if that helps.
This is very far from an actual solution, but in case someone only wants to change the colors for a screenshot in a paper or presentation its a quick workaround:
Open your browser dev tools (F12)
Search for the color code you want to change (the default orange is #ff7043) and replace it with the color you want
As suggested here, creating (and pointing tensorboard to) a symlink of a run's logdir is one workaround to change the color used to plot that run.