Python Scikit learn: Get observations of each species from iris data
Python Machine learning Iris Basic: Exercise-6 with Solution
Write a Python program to get observations of each species (setosa, versicolor, virginica) from iris data.
Sample Solution:
Python Code:
import pandas as pd
data = pd.read_csv("iris.csv")
print("Observations of each species:")
print(data['Species'].value_counts())
Sample Output:
Observations of each species: Iris-setosa 50 Iris-versicolor 50 Iris-virginica 50 Name: Species, dtype: int64
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to get observations of each species (setosa, versicolor, virginica) from iris data.
Next: Write a Python program to drop Id column from a given Dataframe and print the modified part. Call iris.csv to create the Dataframe.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework