How to format numbers in Julia DataFrames notebook? - dataframe

Using Julia and DataFrames.jl, Floats display in the notebook dataframe output like this:
5.97551e5
7.37884e5
3.10031e5
9.6429e5
2.40817e5
How would one get the notebook to display them like, for example,
5.97e5
7.37e5
3.10e5
9.64e5
2.40e5
Or using Formatting.jl with the format format(x,commas=true,autoscale=:finance,precision=2):
597.55k
737.88k
310.03k
964.29k
240.81k

Related

How to increase length of ouput table or dataframe in Jupyter Notebook?

I am working on the Jupyter notebook and have been facing issues in increasing the length of the output of the Jupyter Notebook. I can see the output as follows:
I tried increasing the default length of the columns in pandas with no success. Can you please help me with it?
If you were using the typical way to view a dataframe in Jupyter (see my puzzelment about your screenshot in my comments to your original post) it would be things like this:
adapted from answer to 'Pretty-print an entire Pandas Series / DataFrame'
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
display(df)
(Note that will work with the text-based viewing, too. Note it uses print(df) in the answer to 'Pretty-print an entire Pandas Series / DataFrame'.
Adjust the 'display.max_colwidth' if you want the entire column text to show:
with pd.option_context('display.max_rows', None, 'display.max_columns', None,'display.max_colwidth', -1):
display(df)
(If you prefer text like you posted, replace display() with print()
Generally with the solutions above the view window in Jupyter will get scrollbars so you can navigate to view all still.
You can also set the number of rows to show to be lower to save space, see example here.
You may also be interested in Pandas dataframe hide index functionality? or Using python / Jupyter Notebook, how to prevent row numbers from printing?.
As pointed out here, setting some some global options is covered in the Pandas Documentation for top-level options.
For display() to work these days you don't need to do anything extra. But if your are using old Jupyter or it doesn't work then try adding towards the top of your notebook file and running the following as a cell first:
from IPython.display import display

display output pandas dataframe in rstudio

One question please.
I like to use rstudio to code in python and R, but when I print a pandas dataframe I get output that doesn't use all the space. It is not very friendly and it is worse if I have more variables.
As shown in the attached image.
Is there a way to display the columns to the right like we do with tibble in r?
Thanks!
I have tried using these options but it doesn't work.
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)

How to move pandas table to the middle of the notebook?

I currently have a pandas table (type is pandas.Styler) and I want to move the table to the middle of the jupyter notebook so when I convert it to html. The table should be aligned center of the report.

Pandas - format of values

Here is my file, which I read in to pandas dataframe using read_csv.
import pandas as pd
df_from =pd.read_csv(r'some path')
if you look the file column ('NetworthIndicator_Rollup') values look good, but when I display dataframe in Jupyter or plot heatmap, some of the index values are not correctly formatted. Here is preview of incorrect formatting:
In particular 'NetworthIndicator_Rollup' is missing spaces. However when I execute: df_from['NetworthIndicator_Rollup'], everything looks good:
What is wrong?

nbconvert to convert from notebook to Latex/PDF cuts off the dataframe

I have a notebook that displays lots of dataframe tables in HTML format. However when I used nbconvert to convert the notebook to latex and to PDF, some tables with wider body gets cut off. I have tried using pd.set_option('display.width', xxxx) but it didn't seem to work. It seems that the issue is not in the display of the pandas dataframe( the table is displayed just fine on the notebook ), but rather in converting the notebook to Latex/PDF. Is there anything I can do to resolve this problem?