Python Forum
How many unique values of quality are in this dataset?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How many unique values of quality are in this dataset?
#1
Hi there, I got stuck on this problem:

I need to answer this question: How many unique values of quality are in this dataset?

I tried out to answer this question with this function:
import pandas as pd
import numpy as np
% matplotlib inline

df = pd.read_csv(r'C:\Users\DSule\Desktop\python\winequality-red.csv', sep =';')
res = pd.df['quality'].nunique()
and get this error
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-52-d254f858d008> in <module>()
----> 1 res = pd.df['quality'].nunique()

AttributeError: module 'pandas' has no attribute 'df'
Can somebody help?
Reply
#2
(May-20-2018, 01:23 PM)Jack_Sparrow Wrote:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-52-d254f858d008> in <module>()
----> 1 res = pd.df['quality'].nunique()

AttributeError: module 'pandas' has no attribute 'df'
Can somebody help?

Well, it does not Doh . Read your code again - why pd.df?
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas: Compute the % of the unique values in a column JaneTan 1 1,756 Oct-25-2021, 07:55 PM
Last Post: jefsummers
  Pandas + Groupby + Filter unique values JosepMaria 1 2,838 Jun-15-2020, 08:15 AM
Last Post: JosepMaria
  spread values of dataset equally over fixed number of bins moose_man 3 2,470 Oct-30-2019, 07:41 PM
Last Post: ichabod801
  Join Predicted values with test dataset bhuwan 4 10,299 Mar-28-2019, 12:42 AM
Last Post: bhuwan
  Get max values based on unique values in another list - python Antonio 8 8,354 Jun-12-2018, 07:49 PM
Last Post: Mekire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020