How to delete instances with missing values in Python?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

How to delete instances with missing values in Python?

How to delete instances with missing values in Python?

This recipe helps you delete instances with missing values in Python

0
This python source code does the following: 1. Creates your own numpy array 2. Selects the rows with NaN values and removes them
In [1]:
## How to delete instances with missing values in Python 
def Kickstarter_Example_29():
    print()
    print(format('How to delete instances with missing values in Python', '*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # Load libraries
    import numpy as np

    # Create feature matrix
    X = np.array([[1.1, 11.1],
                  [2.2, 22.2],
                  [3.3, 33.3],
                  [4.4, 44.4],
                  [np.nan, 55]])

    # Remove observations with missing values
    X = X[~np.isnan(X).any(axis=1)]
    print(); print(X)

Kickstarter_Example_29()
**************How to delete instances with missing values in Python***************

[[ 1.1 11.1]
 [ 2.2 22.2]
 [ 3.3 33.3]
 [ 4.4 44.4]]

Relevant Projects

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.