0
$\begingroup$

I am looking to download and use Solar Flare Data Set (https://archive.ics.uci.edu/ml/datasets/Solar+Flare) but unable to figure out how to get the pandas dataframe from the file that is being downloaded.

Can you please help me create a pandas dataframe from the file downloaded from the give URL?

$\endgroup$

1 Answer 1

1
$\begingroup$

Since these are .data files, they are not tab delimited. Instead, all of the data inside each of these files are space delimited. What this means is that you can read in these files in pandas like you would any other data file, except you have to change the separator.

This looks like this:

pd.read_csv('file_path', sep=' ')

You can read more about the pandas read_csv() method on its documentation page.

You can verify that these files are space delimited by opening up one of the files in a text editor:

*******DATA1; 1969 FLARE DATA  (02/13/69 to 03/27/69) *******
C S O 1 2 1 1 2 1 2 0 0 0
D S O 1 3 1 1 2 1 2 0 0 0
C S O 1 3 1 1 2 1 1 0 0 0
D S O 1 3 1 1 2 1 2 0 0 0
D A O 1 3 1 1 2 1 2 0 0 0
D A O 1 2 1 1 2 1 2 0 0 0
D A O 1 2 1 1 2 1 1 0 0 0
D A O 1 2 1 1 2 1 2 0 0 0
$\endgroup$
2
  • $\begingroup$ Is the file path the same as the URL? Please add the code for downloading from the URL. $\endgroup$
    – Sachin
    Apr 28, 2023 at 1:18
  • $\begingroup$ The file path is whichever path points to the location on your computer where the downloaded file is. See here $\endgroup$
    – Ethan
    Apr 28, 2023 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.