Creating a DataFrame with Iris Dataset
Iris DataFrame Build
Import sklearn
from sklearn.datasets import load_iris.
Load Data
iris = load_iris() — built-in dataset bundled with scikit-learn.
Build DataFrame
df = pd.DataFrame(iris.data, columns=iris.feature_names).
Add Target
df['species'] = iris.target. Now you have a complete labeled DataFrame.
Noble Desktop's Python Machine Learning Bootcamp covers scikit-learn, Keras, and applied ML.
This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.
Convert the Iris dataset into a pandas DataFrame, map numerical targets to species names, and add this as a new column. Watch this tutorial to learn the key concepts and techniques.