This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi all, I am a newbie Python user, and I'm dumb as hell. I can't figure out how to figure out the assignment, which I will post here:
Read in Student_Grade_Prediction2.csv as Students_df and create a database called Students.
Remember that you also need to create a cursor to execute the commands below.- Select all the students who scored less than or equal to 12 on the first exam (G1) ordered in
descending order by the first exam scores.
- Select all the students who scored less than or equal to 12 on the first exam (G1) ordered in
As you can see, I am supposed to read in a csv file, create a database, and then a table with a cursor? I don't know really, this is where I get lost. Here is my code:
import sqlite3
con = sqlite3.connect('Students_df')
cursor = conn.cursor()
import pandas as pd
Students = pd.read_csv(
'Student_Grade_Prediction2.csv')
Students.to_sql("Student_records", con, if_exists = "replace")
cursor.execute("CREATE TABLE IF NOT EXISTS students (ID INT PRIMARY KEY, school TEXT, sex TEXT, age INT, address TEXT, famsize TEXT, Pstatus TEXT, Medu INT, Fedu INT, Mjob TEXT, Fjob TEXT, reason TEXT, guardian TEXT, traveltime INT, studytime INT, failures INT, schoolsup TEXT, famsup TEXT, paid TEXT, activities TEXT, nursery TEXT, higher TEXT, internet TEXT, romantic TEXT, famrel INT, freetime INT, goout INT, Dalc INT, Walc INT, health INT, absences INT, G1 INT, G2 INT, G3 INT;))"
I'm getting an "unexpected EOF while parsing" error
Sorry if this is against rules, I just really need help. Thanks in advance
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/pythonhelp/...