Skip to content

Commit b673405

Browse files
committed
Lots of Progress
1 parent bb433ed commit b673405

11 files changed

+6003
-492
lines changed

lst.ipynb renamed to 1.lst_org copy 2.ipynb

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,9 +2086,17 @@
20862086
},
20872087
{
20882088
"cell_type": "code",
2089-
"execution_count": 51,
2089+
"execution_count": 1,
20902090
"metadata": {},
20912091
"outputs": [
2092+
{
2093+
"name": "stderr",
2094+
"output_type": "stream",
2095+
"text": [
2096+
"/var/folders/bn/fsn7y0ds1vl73pjmxwqvqdxw0000gn/T/ipykernel_10456/3895599987.py:5: DtypeWarning: Columns (0,1,2) have mixed types. Specify dtype option on import or set low_memory=False.\n",
2097+
" book_tags = pd.read_csv('/Users/siyaksares/Developer/GitHub/ReadersRadarProject/book_tags.csv')\n"
2098+
]
2099+
},
20922100
{
20932101
"name": "stdout",
20942102
"output_type": "stream",
@@ -2104,28 +2112,59 @@
21042112
"22753 owned-books\n",
21052113
"30521 to-buy\n",
21062114
"30574 to-read\n",
2115+
"39461 books-i-own\n",
2116+
"42971 currently-reading\n",
2117+
"45811 favorites\n",
2118+
"45997 fiction\n",
2119+
"51467 kindle\n",
2120+
"52299 library\n",
2121+
"56997 owned\n",
2122+
"57007 owned-books\n",
2123+
"64775 to-buy\n",
2124+
"64828 to-read\n",
21072125
"Name: tag_name, dtype: object\n",
2126+
"Selected tag: fiction\n",
21082127
"Selected Book:\n",
2109-
" title\n",
2110-
"1978 Dead Ever After (Sookie Stackhouse, #13)\n"
2128+
"Empty DataFrame\n",
2129+
"Columns: [title]\n",
2130+
"Index: []\n"
21112131
]
21122132
}
21132133
],
21142134
"source": [
21152135
"import pandas as pd\n",
21162136
"\n",
2117-
"tags = pd.read_csv('tags.csv')\n",
2118-
"book_tags = pd.read_csv('book_tags.csv')\n",
2137+
"# Read tags and book tags data\n",
2138+
"tags = pd.read_csv('/Users/siyaksares/Developer/GitHub/ReadersRadarProject/tags.csv')\n",
2139+
"book_tags = pd.read_csv('/Users/siyaksares/Developer/GitHub/ReadersRadarProject/book_tags.csv')\n",
2140+
"\n",
2141+
"# Convert tag_id column to integer type in both DataFrames\n",
2142+
"tags['tag_id'] = pd.to_numeric(tags['tag_id'], errors='coerce')\n",
2143+
"book_tags['tag_id'] = pd.to_numeric(book_tags['tag_id'], errors='coerce')\n",
2144+
"\n",
2145+
"# Drop rows with NaN values in the tag_id column\n",
2146+
"tags.dropna(subset=['tag_id'], inplace=True)\n",
2147+
"book_tags.dropna(subset=['tag_id'], inplace=True)\n",
2148+
"\n",
2149+
"# Identify the top 10 most used tags\n",
21192150
"top_tags = book_tags.groupby('tag_id').count().sort_values(by='count', ascending=False).head(10)\n",
21202151
"top_tag_names = tags[tags['tag_id'].isin(top_tags.index)]['tag_name']\n",
2152+
"\n",
2153+
"# Display top tag names\n",
21212154
"print(\"Top 10 Most Used Tags:\")\n",
21222155
"print(top_tag_names)\n",
2123-
"selected_tag = input(\"Please select a tag: \")\n",
2124-
"selected_tag_id = tags[tags['tag_name'] == selected_tag]['tag_id'].values\n",
2125-
"if not selected_tag_id:\n",
2126-
" print(\"Invalid label. Please select an existing tag.\")\n",
2156+
"\n",
2157+
"# Request user input to select a tag\n",
2158+
"selected_tag = input(\"Please select a tag: \").strip() # Strip whitespace from the input\n",
2159+
"print(\"Selected tag:\", selected_tag)\n",
2160+
"\n",
2161+
"# Check if the selected tag is empty\n",
2162+
"if not selected_tag:\n",
2163+
" print(\"No tag selected. Please enter a tag.\")\n",
2164+
"elif selected_tag not in top_tag_names.values:\n",
2165+
" print(\"Invalid label. Please select a tag from the top 10 most used tags.\")\n",
21272166
"else:\n",
2128-
" selected_tag_id = selected_tag_id[0]\n",
2167+
" selected_tag_id = tags[tags['tag_name'] == selected_tag]['tag_id'].values[0]\n",
21292168
" filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]\n",
21302169
" if not filtered_books.empty:\n",
21312170
" random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]\n",
@@ -2134,7 +2173,7 @@
21342173
" print(\"Selected Book:\")\n",
21352174
" print(selected_book)\n",
21362175
" else:\n",
2137-
" print(\"No books were found associated with the selected tag.\")"
2176+
" print(\"No books were found associated with the selected tag.\")\n"
21382177
]
21392178
},
21402179
{
@@ -2174,7 +2213,7 @@
21742213
"name": "python",
21752214
"nbconvert_exporter": "python",
21762215
"pygments_lexer": "ipython3",
2177-
"version": "3.12.0"
2216+
"version": "3.12.2"
21782217
}
21792218
},
21802219
"nbformat": 4,

lst_org.ipynb renamed to 1.lst_org copy.ipynb

Lines changed: 157 additions & 152 deletions
Large diffs are not rendered by default.

2.lst-to-solve 2.ipynb

Lines changed: 3364 additions & 0 deletions
Large diffs are not rendered by default.

3.lst-to-solve 3.ipynb

Lines changed: 2281 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# ReadersRadarProject
2-
Python Book Recomandation Project
2+
3+
Python Book Recomandation Project

Start.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

book_tags.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
goodreads_book_id,tag_id,count
32
1,30574,167697
43
1,11305,37174

books.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
id,book_id,best_book_id,work_id,books_count,isbn,isbn13,authors,original_publication_year,original_title,title,language_code,average_rating,ratings_count,work_ratings_count,work_text_reviews_count,ratings_1,ratings_2,ratings_3,ratings_4,ratings_5,image_url,small_image_url
32
1,2767052,2767052,2792775,272,439023483,9.78043902348e+12,Suzanne Collins,2008.0,The Hunger Games,"The Hunger Games (The Hunger Games, #1)",eng,4.34,4780653,4942365,155254,66715,127936,560092,1481305,2706317,https://images.gr-assets.com/books/1447303603m/2767052.jpg,https://images.gr-assets.com/books/1447303603s/2767052.jpg
43
2,3,3,4640799,491,439554934,9.78043955493e+12,"J.K. Rowling, Mary GrandPré",1997.0,Harry Potter and the Philosopher's Stone,"Harry Potter and the Sorcerer's Stone (Harry Potter, #1)",eng,4.44,4602479,4800065,75867,75504,101676,455024,1156318,3011543,https://images.gr-assets.com/books/1474154022m/3.jpg,https://images.gr-assets.com/books/1474154022s/3.jpg

note.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import pandas as pd
2+
3+
tags = pd.read_csv('/Users/siyaksares/Developer/GitHub/ReadersRadarProject/tags.csv')
4+
book_tags = pd.read_csv('/Users/siyaksares/Developer/GitHub/ReadersRadarProject/book_tags.csv')
5+
6+
tags['tag_id'] = pd.to_numeric(tags['tag_id'], errors='coerce')
7+
book_tags['tag_id'] = pd.to_numeric(book_tags['tag_id'], errors='coerce')
8+
9+
tags.dropna(subset=['tag_id'], inplace=True)
10+
book_tags.dropna(subset=['tag_id'], inplace=True)
11+
12+
top_tags = book_tags.groupby('tag_id').count().sort_values(by='count', ascending=False).head(10)
13+
top_tag_names = tags[tags['tag_id'].isin(top_tags.index)]['tag_name']
14+
15+
print("Top 10 Most Used Tags:")
16+
print(top_tag_names)
17+
18+
'''
19+
selected_tag = input("Please select a tag: ") # Strip whitespace from the input
20+
print("Selected tag:", selected_tag)
21+
22+
if not selected_tag:
23+
print("No tag selected. Please enter a tag.")
24+
elif selected_tag not in top_tag_names.values:
25+
print("Invalid label. Please select a tag from the top 10 most used tags.")
26+
else:
27+
selected_tag_id = tags[tags['tag_name'] == selected_tag]['tag_id'].values[0]
28+
filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]
29+
if not filtered_books.empty:
30+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
31+
books = pd.read_csv('books.csv')
32+
selected_book = books[books['book_id'] == random_book_id][['title']]
33+
print("Selected Book:")
34+
print(selected_book)
35+
else:
36+
print("No books were found associated with the selected tag.")'''
37+
38+
'''
39+
selected_tag = input("Please select a tag: ") # Strip whitespace from the input
40+
print("Selected tag:", selected_tag)
41+
42+
if not selected_tag:
43+
print("No tag selected. Please enter a tag.")
44+
elif selected_tag not in top_tag_names.values:
45+
print("Invalid label. Please select a tag from the top 10 most used tags.")
46+
else:
47+
selected_tag_id = tags[tags['tag_name'] == selected_tag]['tag_id'].values[0]
48+
filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]
49+
if not filtered_books.empty:
50+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
51+
books = pd.read_csv('books.csv')
52+
selected_book = books[books['book_id'] == random_book_id][['title']]
53+
print("Selected Book:")
54+
print(selected_book)
55+
else:
56+
print("No books were found associated with the selected tag.")
57+
'''
58+
59+
'''
60+
selected_tag_lower = selected_tag.lower() # Convert selected tag to lowercase
61+
62+
if not selected_tag_lower:
63+
print("No tag selected. Please enter a tag.")
64+
elif selected_tag_lower not in top_tag_names.str.lower().values: # Convert tag names to lowercase for comparison
65+
print("Invalid label. Please select a tag from the top 10 most used tags.")
66+
else:
67+
filtered_books = book_tags[book_tags['tag_name'].str.lower().str.contains(selected_tag_lower)]
68+
if not filtered_books.empty:
69+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
70+
books = pd.read_csv('books.csv')
71+
selected_book = books[books['book_id'] == random_book_id][['title']]
72+
print("Selected Book:")
73+
print(selected_book)
74+
else:
75+
print("No books were found associated with the selected tag.")'''
76+
77+
'''
78+
selected_tag = input("Please select a tag: ") # Strip whitespace from the input
79+
print("Selected tag:", selected_tag)
80+
81+
if not selected_tag:
82+
print("No tag selected. Please enter a tag.")
83+
elif selected_tag_lower not in top_tag_names.str.lower().values: # Convert tag names to lowercase for comparison
84+
print("Invalid label. Please select a tag from the top 10 most used tags.")
85+
else:
86+
selected_tag_lower = selected_tag.lower() # Convert selected tag to lowercase
87+
selected_tag_id = tags[tags['tag_name'].str.lower() == selected_tag_lower]['tag_id'].values[0]
88+
filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]
89+
if not filtered_books.empty:
90+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
91+
books = pd.read_csv('books.csv')
92+
selected_book = books[books['book_id'] == random_book_id][['title']]
93+
print("Selected Book:")
94+
print(selected_book)
95+
else:
96+
print("No books were found associated with the selected tag.")'''
97+
98+
'''
99+
selected_tag = input("Please select a tag: ") # Strip whitespace from the input
100+
print("Selected tag:", selected_tag)
101+
102+
if not selected_tag:
103+
print("No tag selected. Please enter a tag.")
104+
elif selected_tag_lower not in top_tag_names.str.lower().values: # Convert tag names to lowercase for comparison
105+
print("Invalid label. Please select a tag from the top 10 most used tags.")
106+
else:
107+
selected_tag_lower = selected_tag.lower() # Convert selected tag to lowercase
108+
selected_tag_id_series = tags[tags['tag_name'].str.lower() == selected_tag_lower]['tag_id']
109+
if not selected_tag_id_series.empty:
110+
selected_tag_id = selected_tag_id_series.values[0]
111+
filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]
112+
if not filtered_books.empty:
113+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
114+
books = pd.read_csv('books.csv')
115+
selected_book = books[books['book_id'] == random_book_id][['title']]
116+
print("Selected Book:")
117+
print(selected_book)
118+
else:
119+
print("No books were found associated with the selected tag.")
120+
else:
121+
print("Invalid tag. Please select a valid tag.")'''
122+
123+
selected_tag = input("Please select a tag: ").strip() # Strip whitespace from the input
124+
print("Selected tag:", selected_tag)
125+
126+
if not selected_tag:
127+
print("No tag selected. Please enter a tag.")
128+
else:
129+
selected_tag_lower = selected_tag.lower() # Convert selected tag to lowercase
130+
top_tag_names_lower = top_tag_names.str.lower() # Convert top tag names to lowercase for comparison
131+
if selected_tag_lower not in top_tag_names_lower.values:
132+
print("Invalid label. Please select a tag from the top 10 most used tags.")
133+
else:
134+
selected_tag_id_series = tags[tags['tag_name'].str.lower() == selected_tag_lower]['tag_id']
135+
if not selected_tag_id_series.empty:
136+
selected_tag_id = selected_tag_id_series.values[0]
137+
filtered_books = book_tags[book_tags['tag_id'] == selected_tag_id]
138+
if not filtered_books.empty:
139+
random_book_id = filtered_books.sample(1)['goodreads_book_id'].values[0]
140+
books = pd.read_csv('books.csv')
141+
selected_book = books[books['book_id'] == random_book_id][['title']]
142+
print("Selected Book:")
143+
print(selected_book)
144+
else:
145+
print("No books were found associated with the selected tag.")
146+
else:
147+
print("Invalid tag. Please select a valid tag.")
148+

0 commit comments

Comments
 (0)