-
Notifications
You must be signed in to change notification settings - Fork 0
New user rating #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GayathriSrividya
wants to merge
151
commits into
master
Choose a base branch
from
new-user-rating
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
e1597ae
Code to read csv file
GayathriSrividya ec397d6
code to update user rating
GayathriSrividya 376edf4
required packages
GayathriSrividya 2bfe168
-S
GayathriSrividya 269bc60
install required packages
GayathriSrividya 2dabc71
install packages
GayathriSrividya 0b7ffb3
python class to update user ratig
GayathriSrividya e23d808
required dependencies
GayathriSrividya 65d9473
python class to update rating
GayathriSrividya 33b8beb
python code to read and update csv file
GayathriSrividya 0970255
required dependencies
GayathriSrividya 9fb4a4e
Delete ratings_class.py
RajavarapuGayathri b6f15b6
csv file
GayathriSrividya 719d4b4
configuration file to connect postgreSQL database
977bf45
python code to convert csv file to postgreSQL database
a119859
gitignore commit
456582a
python code to convert csv file to postgreSQL database
2dc8db4
configurations for postgreSQL server
fe17920
gitignore commit
4930c0f
configurations for postgreSQL server
6b3083e
python code to convert csv to postgresql table
396ea23
python class to handle CRUD functions
a89d470
gitignore commit
21c8bb3
gitignore commit
ecad137
Merge branch 'new-user-rating' of github.com:GayathriSrividya/trainin…
66883d7
configuration file for postgreSQL
d924ff2
gitignore commit
17f75fc
python code to convert csv file to postgresql database
5a3f74f
configuration file for postgreSQL
b605091
python code to convert dcsv file to postgresql table
efe2951
python code to convert csv file to postgresql table
c6a0bd8
python class to manage records of postgreSQL table
02ebc90
configuration file forpostgresql
a231559
initial commit
9fb68c3
configuration file for postgresql
e1ed18d
python code to convert csv file to pandas dataframe
2f17c85
python class to update dataframe attributes
c07c936
python class to manage records of postgreSQL table
2216b3e
required dependencies
df8b36b
add sql queries
e3af4a1
python class to manage records of postgreSQL table
1009360
python code to convert csv file to postgresql table
f6ab699
python class to manage records of postgreSQL table
231e2d5
python code to convert csv file to postgresql table
0ea2a9e
python class to manage records of postgreSQL table
96ed84f
python class to manage records of postgreSQL table
c3c3d44
initial commit
b078c44
initial commit
4e64ef2
python cod eto convert csv file to pandas dataframe
41f0224
python code to convert csv file to pandas dataframe
d49134b
python class to update dataframe attributes
55199cf
python code to convert csv file to postgreSQL table
d0dbed5
python class to manage records in postgreSQL table
57a5422
initial commit
d3dc6a3
python code
e15226e
initial commit
757759b
initial commit
2658591
configuration file for postgreSQL
5092fcc
python code to convert csv file to pandas dataframe
62dc983
pythoon code to convert csv file to postgreSQL table
cca64ce
python class to manage records of postgreSQL table
abd50d1
python class to manage records of postgreSQL table
a79dd95
README commit
e99dad8
README commit
3867a44
Update README.md
GayathriSrividya 36d3209
Update README.md
GayathriSrividya a02acb6
Update README.md
GayathriSrividya 9fa0b9d
Update README.md
GayathriSrividya aba7d62
Update README.md
GayathriSrividya a6d2620
configuration file for postgreSQL
00326a9
required dependencies
79d4f00
initial commit
84790a8
python code to convert pandas dataframe to postgreSQL database
fb907c0
python class to manage records of postgreSQL table
4a52f0f
Delete db_query.py
GayathriSrividya d47bcdb
Delete df_to_db.py
GayathriSrividya a35b5ea
python class to manage records of postgreSQL table
de0c8ff
unit test cases
04ffe6d
unittest cases
5b6dc9f
initial commit
94b653b
configuration file for postgreSQL
2fe7004
python code to convert csv file to pandas dataframe
e192c73
python class to manage records of postgreSQL table
4c7cb69
python code to convert pandas dataframe to postgreSQL database
da8ee8f
python class to manage records of postgreSQL table
90c8c42
python code to convert csv file to pandas dataframe
fd11897
python class to manage records of postgreSQL table
b735bb7
required dependencies
cf5860a
python class to update dataframe attributes
b4d4c3d
initial commit
e212455
required dependencies
4342813
unittest cases
7d169d4
project setup
9e246a4
required dependencies
cedc479
csv to postgresql using pandas
a2b739e
updated .gitignore
6774beb
configuration file for postgreSQL
7eacd81
params for testv1.py file
d3d9a3f
params for testv2.py file
2f33c5e
uniitest cases
025ace5
uniitest cases
762908a
json file with sql queries
f31796a
python code to convert csv file to pandas dataframe
dd90615
python class to update dataframe attributes
6cc39c6
python class to manage records of postgreSQL table
3b2a826
python code to convert pandas dataframe to postgreSQL database
68cdfb1
Delete test_query.json
GayathriSrividya 5dd5340
Delete v1params.json
GayathriSrividya 69142d4
Delete v2params.json
GayathriSrividya c75dc74
Delete update_ratings.py
GayathriSrividya da136cd
Delete ratings_class.py
GayathriSrividya 06e149d
Delete dataframe.py
GayathriSrividya 2c71eb2
Delete records_class.py
GayathriSrividya c99cc0c
python code to convert pandas dataframe to postgreSQL database
4deb04d
json file with SQL queries
8542d3c
python code to convert pandas dataframe to postgreSQL database
2f3c9ba
python class to update dataframe attributes
e84742c
python code to convert pandas dataframe to postgreSQL database
08c2890
project setup
47fba28
json file with SQL queries
1e7c08e
json file with pandas queries
908642f
python code to convert csv file to pandas dataframe
694dc46
python code to convert cav file to postgreSQL database
f83d689
python class to manage records of postgreSQL table
6536207
python code to convert and manipulate csv file into pandas dataframe
9bb21ec
python class to perform CRUD operations on pandas dataframe
87c695b
params for unittest cases
9f8fcda
unittest cases
03f28fb
python class to manage records in postgreSQL table
1c4bfd6
python class to manage records in postgreSQL table
e35e13f
updated gitignore
3775f2b
updated gitignore
27e8c80
updated gitignore
d9fad1f
updated gitignore
6613b86
updated gitignore
b72183e
updated gitignore
abe3c47
updated gitignore
20f902d
updated gitignore
fd66e54
updated gitignore
cd75670
removing coverage file
29ef2ec
python code to convert and manipulate csv file into pandas dataframe
930401e
unittest cases
e1ef904
unittest cases
2947565
params for unittest cases
61aeee8
python code to convert and manipulate csv file into pandas dataframe
5bcc493
querying on data with pyspark
49bdb9f
pyspark queries
bbd1512
updated gitignore
3a88166
querying on data with pyspark
c403122
pyspark queries
6994d7d
required dependencies
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .coverage | ||
| database.ini | ||
| my-project-env | ||
| __pycache__ | ||
| __init__.py | ||
| htmlcov/ | ||
| Dockerfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "List number of rows in a dataframe": "print(self.ratings.shape[0])", | ||
| "List number of rows by title type": "print(self.ratings['Title Type'].value_counts())", | ||
| "List number of rows by year of rating": "print(pd.DatetimeIndex(self.ratings['Date Rated']).year.value_counts())", | ||
| "List number of rows by year of release": "print(self.ratings['Year'].value_counts())", | ||
| "List top 10 rated titles": "print(self.ratings[['Title', 'Your Rating']].sort_values(by='Your Rating', ascending=False)[:10])", | ||
| "List bottom 10 rated titles": "print(self.ratings[['Title', 'Your Rating']].sort_values(by='Your Rating')[:10])", | ||
| "Fetch histogram of ratings": "print(self.ratings['Your Rating'].value_counts())", | ||
| "List genres by their average ratings, sorted decrementally: ": "self.ratings['Genres']=self.ratings['Genres'].str.split(', ')\nprint(self.ratings.explode('Genres').groupby('Genres')[['Genres', 'Your Rating']].mean().round(decimals=2).sort_values(by='Your Rating', ascending=False))", | ||
| "Filter rows using const id": "print(self.ratings.loc[self.ratings.Const==id])" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "List number of rows in a dataframe": "print(ratings.count())", | ||
| "List number of rows by title type": "ratings.groupBy(ratings['Title Type']).count().sort(desc('count')).show()", | ||
| "List number of rows by year of rating": "ratings.withColumn('Year Rated', year(to_date(col('Date Rated'), 'MM/dd/yyyy'))).groupBy('Year Rated').count().sort(desc('count')).show()", | ||
| "List number of rows by year of release": "ratings.groupBy(ratings.Year).count().sort(asc('Year')).show()", | ||
| "List top 10 rated titles": "ratings.select([ratings['Title'], ratings['Your Rating']]).sort(desc('Your Rating')).show(10)", | ||
| "List bottom 10 rated titles": "ratings.select([ratings['Title'], ratings['Your Rating']]).sort(asc('Your Rating')).show(10)", | ||
| "Fetch histogram of ratings": "ratings.groupBy(ratings['Your rating']).count().sort(asc('Your Rating')).show()", | ||
| "List genres by their average ratings, sorted decrementally: ": "ratings.withColumn('Genres', explode_outer(split('Genres', ', ')).alias('Genres')).groupBy('Genres').agg(round(mean('Your Rating'), 2).alias('Average Rating')).sort(desc('Average Rating')).show(26)", | ||
| "Filter rows using const id": "ratings.where(ratings.Const==input('Enter Const id: ')).show()" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "List total number of records in table: ": "SELECT COUNT(*) FROM ratings;", | ||
| "List number of records by title type: ": "SELECT title_type, COUNT(*) FROM ratings GROUP BY title_type; " , | ||
| "List number of records by year of rating: ": "SELECT EXTRACT(YEAR FROM date_rated) AS year_of_rating, COUNT(*) FROM ratings GROUP BY 1 ORDER BY 1;", | ||
| "List number of records by year of release: ": "SELECT year, COUNT(*) FROM ratings GROUP BY 1 ORDER BY 1;", | ||
| "List the top 10 rated titles: ": "SELECT title, your_rating FROM ratings ORDER BY your_rating DESC LIMIT 10;", | ||
| "List the bottom 10 rated titles: ": "SELECT title, your_rating FROM ratings ORDER BY your_rating LIMIT 10;", | ||
| "List genres by their average ratings, sorted decrementally: ": "SELECT genre, CAST(AVG(your_rating) AS DECIMAL(5,2)) AS average_rating FROM (SELECT DISTINCT(UNNEST(STRING_TO_ARRAY(genres, ', '))) AS genre, your_rating FROM ratings) AS temp GROUP BY genre ORDER BY average_rating DESC;", | ||
| "Fetch histogram of ratings: ": "SELECT your_rating, COUNT(*) FROM ratings GROUP BY 1 ORDER BY 1;", | ||
| "Filter Records from table using Const": "SELECT * FROM ratings WHERE Const=%s" | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import json | ||
| from pyspark.sql import SparkSession | ||
| from pyspark.sql.functions import * | ||
|
|
||
| spark=SparkSession.builder.appName("pyspark_sql").getOrCreate() | ||
| spark.sql("set spark.sql.legacy.timeParserPolicy=LEGACY") | ||
| ratings=spark.read.csv('../data/ratings.csv', header=True, inferSchema=True) | ||
| pyspark_queries=open('../config/pyspark_queries.json') | ||
| query_data=json.load(pyspark_queries) | ||
|
|
||
| # executing pyspark queries one by one | ||
|
|
||
| for query, pdtxt in query_data.items(): | ||
| print(query+':\n') | ||
| exec(pdtxt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pandas==1.4.4 | ||
| datetime==4.5 | ||
| psycopg2==2.9.3 | ||
| unittest2==1.1.0 | ||
| coverage==6.4.4 | ||
| postgres==4.0 | ||
| pyspark==3.3.0 | ||
| py4j==0.10.9.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # import necessary packages | ||
| import pandas as pd | ||
| from ratings import Ratings | ||
| # Read the csv file | ||
| # Load the data in csv file into a Data Frame | ||
|
|
||
| csv_file=pd.read_csv('../../data/ratings.csv', encoding='latin') | ||
|
|
||
| # iterating over the DataFrame rows using df.iterrows() | ||
|
|
||
| for index, row in csv_file[0:10].iterrows(): | ||
|
|
||
| #creating instance for class Ratings | ||
|
|
||
| this_movie =Ratings(row['Const'], row['Your Rating'], row['Date Rated'], row['Title'], row['URL'], row['Title Type'], row['IMDb Rating'], row['Runtime (mins)'], row['Year'], row['Genres'], row['Num Votes'], row['Release Date'], row['Directors']) | ||
| new_rating=input("Enter your rating for "+row['Title']+" : ") | ||
| this_movie.set_rating(new_rating) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # importing necessary modules | ||
| from datetime import datetime | ||
|
|
||
| class Ratings: | ||
| ''' | ||
| Description of class Ratings | ||
|
|
||
| This is a class to update user rating and date rated in pandas dataframe | ||
|
|
||
| atrributes: | ||
| ----------- | ||
| const //contains unique id that represents movie | ||
| your_rating //user rating for the movie | ||
| date_rated //date in which user rating is last updated | ||
| title //movie title | ||
| url //url contains link to access the resource | ||
| title_type //type of movie (eg: movie, short) | ||
| imdb_rating //average rating for the movie | ||
| runtime //total duration | ||
| year //year released | ||
| genres //category of film | ||
| num_votes //number of votes given | ||
| release_date | ||
| directors //list of directors | ||
|
|
||
| methods defined here: | ||
| --------------------- | ||
| get_rating(self) | ||
| returns your_rating value | ||
|
|
||
| set_rating(self, new_rating) | ||
| parameters: | ||
| new_rating | ||
|
|
||
| updates value in your_rating to new_rating | ||
| updates date_rated to current date | ||
|
|
||
| successful updation depends upon the range in which new_rating lies (0 to 10) | ||
|
|
||
| ''' | ||
| def __init__(self, const, your_rating, date_rated, title, url, title_type, imdb_rating, runtime, year, genres, num_votes, release_date, directors): | ||
| ''' | ||
| Default Constructor for Ratings class | ||
|
|
||
| parameters: | ||
| ----------- | ||
| const | ||
| your_rating | ||
| date_rated | ||
| title | ||
| url | ||
| title_type | ||
| imdb_rating | ||
| runtime | ||
| year | ||
| genres | ||
| num_votes | ||
| release_date | ||
| directors | ||
| ''' | ||
| self.const=const | ||
| self.your_rating=your_rating | ||
| self.date_rated=date_rated | ||
| self.title=title | ||
| self.url=url | ||
| self.title_type=title_type | ||
| self.imdb_rating=imdb_rating | ||
| self.runtime=runtime | ||
| self.year=year | ||
| self.genres=genres | ||
| self.num_votes=num_votes | ||
| self.release_date=release_date | ||
| self.directors=directors | ||
|
|
||
| def get_rating(self): | ||
| ''' | ||
| Summary Line | ||
| Extended Description of get_rating(self) | ||
|
|
||
| this method is used to retrieve user rating | ||
| ''' | ||
| return self.your_rating | ||
|
|
||
| def set_rating(self, new_rating): | ||
| ''' | ||
| Summary Line | ||
| Extended Description of set_rating(self, new_rating) | ||
|
|
||
| parameters: | ||
| ---------- | ||
| new_rating //input | ||
| your_rating | ||
| date_rated | ||
|
|
||
| this method is used to update user rating with the input value and also updates the date rated to current date | ||
| the current date will be generated by using folowing commands | ||
| day=datetime.now() | ||
| day=day.strftime("%d/%m/%Y") | ||
|
|
||
| updation will be done only if the input is in valid range i.e, between 0 and 10.0 | ||
| stops execution otherwise | ||
|
|
||
| ''' | ||
|
|
||
| try: | ||
| new_rating=float(new_rating) | ||
| if(new_rating>=0 and new_rating<=10.0): | ||
| self.your_rating=new_rating | ||
| day=datetime.now() | ||
| day=day.strftime("%d/%m/%Y") | ||
| self.date_rated=day | ||
| print("rating updated sucessfully for title {0}\n".format(self.title)) | ||
| else: | ||
| print("\ninvalid input!! must be in between 0 and 10!! \nrating not updated\n") | ||
| return -1 | ||
| except: | ||
| print("\ninvalid input!! must be in between 0 and 10!! \nrating not updated\n") | ||
| return -1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # importing required modules | ||
| import json | ||
|
|
||
| import pandas as pd | ||
|
|
||
| from ratings import Ratings | ||
|
|
||
| # reading csv file | ||
|
|
||
| print("reading file ratings.csv...\n") | ||
| print("converting csv file into pandas dataframe...\n") | ||
| df=pd.read_csv("../../data/ratings.csv", encoding='latin') | ||
| df['Date Rated'] = pd.to_datetime(df['Date Rated']) | ||
| print("csv file is successfully converted into dataframe...\n") | ||
|
|
||
| # creating instance for Ratings class | ||
|
|
||
| this_title=Ratings() | ||
|
|
||
| print("inserting values into database...\n") | ||
|
|
||
| for index, row in df.iterrows(): | ||
| this_title.insert(row) | ||
|
|
||
| print("Values are inserted into the database Successfully. \n") | ||
|
|
||
|
|
||
| # reading json file contains sql queries | ||
|
|
||
| read_queries= open('../../config/read_queries.json') | ||
| query_data = json.load(read_queries) | ||
|
|
||
| # executing sql queries one by one | ||
|
|
||
| for query, sqltext in query_data.items(): | ||
| print(query+"\n") | ||
| if "%s" in sqltext: | ||
| val = input("Enter Const id of title: ") | ||
| this_title.read(sqltext, val) | ||
| else: | ||
| this_title.read(sqltext) | ||
|
|
||
| this_title.update("tt1001526", 7.23) | ||
| this_title.delete("tt1001526") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add steps on how to set up the project and how to execute each script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is commit message saying initial commit?