Python Scikit learn: Get the number of observations, missing values and nan values
Python Machine learning Iris Basic: Exercise-3 with Solution
Write a Python program to get the number of observations, missing values and nan values.
Sample Solution:
Python Code:
import pandas as pd
iris = pd.read_csv("iris.csv")
print(iris.info())
Samole Output:
<class 'pandas.core.frame.DataFrame'> RangeIndex: 150 entries, 0 to 149 Data columns (total 6 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Id 150 non-null int64 1 SepalLengthCm 150 non-null float64 2 SepalWidthCm 150 non-null float64 3 PetalLengthCm 150 non-null float64 4 PetalWidthCm 150 non-null float64 5 Species 150 non-null object dtypes: float64(4), int64(1), object(1) memory usage: 7.2+ KB None
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program using Scikit-learn to print the keys, number of rows-columns, feature names and the description of the Iris data.
Next: Write a Python program to create a 2-D array with ones on the diagonal and zeros elsewhere. Now convert the NumPy array to a SciPy sparse matrix in CSR format.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/machine-learning/scikit-learn/iris/python-machine-learning-scikit-learn-iris-basic-exercise-3.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics