Using .nunique() to get a count of those values for each column

I am a newbie and am trying to get this code to write all the columns without the … in between.

uniqueValues = df.nunique()
print(uniqueValues)

I have used this code in the past it showed me all the columns, but maybe this file has too many?

Thanks!

image

I am guessing df is a Pandas DataFrame, right?

You can set options to change the output formatting. For example to not truncate the output up to 200 rows, use:

import pandas as pd   # The setting works for this way of importing Pandas.

pd.options.display.max_rows = 200

For more details see:
https://pandas.pydata.org/docs/user_guide/options.html

1 Like

I knew there was an easy solution.
I thought this would work and had this in the script, but it wasn’t solving this problem.
pd.option_context(“display.max_rows”, None) because used this in the .describe() and it worked there.

Thank you!

You are welcome.

option_context() is a context manager. You have to use it like this:

with pd.option_context("display.max_rows", None):
    ...
    # Put your code using that option here.

There is a similar function a for permanent change: set_option().