Home > Enterprise >  how do i download a database in python- very basic
how do i download a database in python- very basic

Time:09-22

I just started learning python and am very very new. I plan on using the logistic regression classification to predict incidence of diabetes. I need to download this database(https://www.kaggle.com/uciml/pima-indians-diabetes-database/discussion)

How do i do it? I know that i need to write pd.read_csv eventually, but whats the whole process? do i first download it to drive or something? i would be very greatful if someone could give a step by step answer down to the most obvious detail as i am very new to python. thanks very much

CodePudding user response:

What you want to do are two different actions.

First, you should download the data set to your hard drive. This should not be a problem, because the data set is quite small.

Second, you need to decide, how you want to process the data. Pandas is probably a good choice to do so. Try following code:

import pandas as pd

file_path = "/path/to/csv/file.csv"
my_dataframe = pd.read_csv(file_path)

Do not forget downloading and installing the pandas module. This can be done with pip or a tool like conda. Please, also check the pandas documentation on reading csv files, to execute additional settings (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html).

CodePudding user response:

I can't download the database you want to use without login in the website, so I can see their limiters, quotechars and those things. You tell you need to use pandas read function, so I can attach you here the Pandas manual to use that functions:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html
Don't forget to add the import line to use it, writing 'import pandas as pd'!
Finally, about downloading it, yes, you need to download it, and its recommendable to save it in the same path as your project, so it will be easy for you to specify the path, you now, just 'name.csv'. If you need to save it in another path, keep in mind you will have to tell it when using the read function, like 'dir/to/path/name.csv'.

EDIT: I just saw the message where you talk about "no such file or directory problem". It's what I was talking about un my second pharagraph, keep in mind you need to specify the correct path to the file.

  • Related