How to list unique values in a Pandas DataFrame?

How to list unique values in a Pandas DataFrame?

This recipe helps you list unique values in a Pandas DataFrame

In [1]:
## How to list unique values in a Pandas DataFrame
def Kickstarter_Example_92():
    print(format('How to list unique values in a Pandas DataFrame','*^82'))

    import warnings

    # load libraries
    import pandas as pd

    # Set ipython's max row display
    pd.set_option('display.max_row', 1000)

    # Set iPython's max column width to 50
    pd.set_option('display.max_columns', 50)

    # Create an example dataframe
    data = {'name': ['Jason', 'Molly', 'Tina', 'Tina', 'Amy'],
            'year': [2012, 2012, 2013, 2014, 2014],
            'reports': [4, 24, 31, 2, 3]}
    df = pd.DataFrame(data, index = ['Cochice', 'Pima', 'Santa Cruz',
                                     'Maricopa', 'Yuma'])
    print(); print(df)

    # List unique values in the df['name'] column
    print(); print(

*****************How to list unique values in a Pandas DataFrame******************

             name  year  reports
Cochice     Jason  2012        4
Pima        Molly  2012       24
Santa Cruz   Tina  2013       31
Maricopa     Tina  2014        2
Yuma          Amy  2014        3

['Jason' 'Molly' 'Tina' 'Amy']

Relevant Projects

Big Data Project PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.
Big Data Project Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.
Big Data Project Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.
Big Data Project Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.
Big Data Project Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.
Big Data Project Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.
Big Data Project Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.
Big Data Project Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.
Big Data Project Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.
Big Data Project Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.