0
import pandas
from sklearn.datasets import load_iris
import pandas as pd
import matplotlib.pyplot as plt

data = load_iris()

Like above, I imported an iris data set from sklearn, and then I want to use pandas to load the dataset to do further work, what should I do?

I know that pandas can read datasets from excel, csv, table, etc. But the dataset I expected pandas to read is from sklearn, so I'm really confused. I expect to use pandas to load the dataset.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Katono
  • 28
  • 4
  • https://stackoverflow.com/questions/38105539/how-to-convert-a-scikit-learn-dataset-to-a-pandas-dataset/46379878#46379878 – Naeblis Nov 16 '22 at 06:15

1 Answers1

0

If I'm not mistaken, pandas needs to have the file opened first, so I would recommend using the

with open(r"filepath.ext", "r") as f:
    data = f.read()

and then manipulate that "data" variable with the stuff that sklearn's "load_iris" function can do, or perhaps other sklearn methods. Unfortunately, I'm not as familiar with the sklearn module, but hopefully this get's you moving in the right direction!

  • I already know that I can use the filepath to read a dataset, I just want to find a way to use pandas to read the dataset loaded from sklearn, I don't even know if there exists a way enables me to do that but thx lol – Katono Nov 16 '22 at 05:28