File size: 106,010 Bytes
391de07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "04f8450b",
"metadata": {},
"outputs": [],
"source": [
"\n",
"import pandas as pd\n",
"\n",
"books = pd.read_csv(\"books_cleaned.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ab2829de",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>categories</th>\n",
" <th>count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Fiction</td>\n",
" <td>2111</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Juvenile Fiction</td>\n",
" <td>390</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Biography & Autobiography</td>\n",
" <td>311</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>History</td>\n",
" <td>207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Literary Criticism</td>\n",
" <td>124</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>474</th>\n",
" <td>Aged women</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>475</th>\n",
" <td>Imperialism</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>476</th>\n",
" <td>Human-animal relationships</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>477</th>\n",
" <td>Amish</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>478</th>\n",
" <td>Human cloning</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>479 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" categories count\n",
"0 Fiction 2111\n",
"1 Juvenile Fiction 390\n",
"2 Biography & Autobiography 311\n",
"3 History 207\n",
"4 Literary Criticism 124\n",
".. ... ...\n",
"474 Aged women 1\n",
"475 Imperialism 1\n",
"476 Human-animal relationships 1\n",
"477 Amish 1\n",
"478 Human cloning 1\n",
"\n",
"[479 rows x 2 columns]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books[\"categories\"].value_counts().reset_index()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "30f187ba",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>categories</th>\n",
" <th>count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Fiction</td>\n",
" <td>2111</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Juvenile Fiction</td>\n",
" <td>390</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Biography & Autobiography</td>\n",
" <td>311</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>History</td>\n",
" <td>207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Literary Criticism</td>\n",
" <td>124</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Religion</td>\n",
" <td>117</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Philosophy</td>\n",
" <td>117</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Comics & Graphic Novels</td>\n",
" <td>116</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Drama</td>\n",
" <td>86</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Juvenile Nonfiction</td>\n",
" <td>57</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Science</td>\n",
" <td>56</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Poetry</td>\n",
" <td>51</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" categories count\n",
"0 Fiction 2111\n",
"1 Juvenile Fiction 390\n",
"2 Biography & Autobiography 311\n",
"3 History 207\n",
"4 Literary Criticism 124\n",
"5 Religion 117\n",
"6 Philosophy 117\n",
"7 Comics & Graphic Novels 116\n",
"8 Drama 86\n",
"9 Juvenile Nonfiction 57\n",
"10 Science 56\n",
"11 Poetry 51"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books[\"categories\"].value_counts().reset_index().query(\"count > 50\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "672caf81",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>isbn10</th>\n",
" <th>title</th>\n",
" <th>authors</th>\n",
" <th>categories</th>\n",
" <th>thumbnail</th>\n",
" <th>description</th>\n",
" <th>published_year</th>\n",
" <th>average_rating</th>\n",
" <th>num_pages</th>\n",
" <th>ratings_count</th>\n",
" <th>agg_of_book</th>\n",
" <th>title_and_subtitle</th>\n",
" <th>tagged_description</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>9780006646006</td>\n",
" <td>000664600X</td>\n",
" <td>Ocean Star Express</td>\n",
" <td>Mark Haddon;Peter Sutton</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=I2QZA...</td>\n",
" <td>Joe and his parents are enjoying a summer holi...</td>\n",
" <td>2002.0</td>\n",
" <td>3.50</td>\n",
" <td>32.0</td>\n",
" <td>1.0</td>\n",
" <td>23.0</td>\n",
" <td>Ocean Star Express</td>\n",
" <td>9780006646006 Joe and his parents are enjoying...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>9780020442608</td>\n",
" <td>0020442602</td>\n",
" <td>The voyage of the Dawn Treader</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=fDD3C...</td>\n",
" <td>The \"Dawn Treader\" is the first ship Narnia ha...</td>\n",
" <td>1970.0</td>\n",
" <td>4.09</td>\n",
" <td>216.0</td>\n",
" <td>2869.0</td>\n",
" <td>55.0</td>\n",
" <td>The voyage of the Dawn Treader</td>\n",
" <td>9780020442608 The \"Dawn Treader\" is the first ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>9780030547744</td>\n",
" <td>0030547741</td>\n",
" <td>Where the Red Fern Grows</td>\n",
" <td>Wilson Rawls</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=IHpRw...</td>\n",
" <td>A young boy living in the Ozarks achieves his ...</td>\n",
" <td>2000.0</td>\n",
" <td>4.37</td>\n",
" <td>288.0</td>\n",
" <td>95.0</td>\n",
" <td>25.0</td>\n",
" <td>Where the Red Fern Grows: The Story of Two Dog...</td>\n",
" <td>9780030547744 A young boy living in the Ozarks...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>9780060000141</td>\n",
" <td>0060000147</td>\n",
" <td>Poppy's Return</td>\n",
" <td>Avi</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=XbcMJ...</td>\n",
" <td>There's trouble at Gray House, the girlhood ho...</td>\n",
" <td>2006.0</td>\n",
" <td>3.99</td>\n",
" <td>256.0</td>\n",
" <td>1086.0</td>\n",
" <td>19.0</td>\n",
" <td>Poppy's Return</td>\n",
" <td>9780060000141 There's trouble at Gray House, t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>9780060001537</td>\n",
" <td>0060001534</td>\n",
" <td>Diary of a Spider</td>\n",
" <td>Doreen Cronin</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=UWvZo...</td>\n",
" <td>This is the diary ... of a spider. But don't b...</td>\n",
" <td>2005.0</td>\n",
" <td>4.25</td>\n",
" <td>40.0</td>\n",
" <td>7903.0</td>\n",
" <td>20.0</td>\n",
" <td>Diary of a Spider</td>\n",
" <td>9780060001537 This is the diary ... of a spide...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4845</th>\n",
" <td>9781590385814</td>\n",
" <td>1590385810</td>\n",
" <td>Fablehaven</td>\n",
" <td>Brandon Mull</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=tbVIP...</td>\n",
" <td>When Kendra and Seth go to stay at their grand...</td>\n",
" <td>2006.0</td>\n",
" <td>4.09</td>\n",
" <td>351.0</td>\n",
" <td>111896.0</td>\n",
" <td>19.0</td>\n",
" <td>Fablehaven</td>\n",
" <td>9781590385814 When Kendra and Seth go to stay ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4930</th>\n",
" <td>9781596792500</td>\n",
" <td>1596792507</td>\n",
" <td>Sherlock Holmes and the Case of the Hound of t...</td>\n",
" <td>Arthur Conan Doyle;Malvina G. Vogel</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=EWgWP...</td>\n",
" <td>Sherlock Holmes and Dr. Watson travel to the b...</td>\n",
" <td>2005.0</td>\n",
" <td>4.51</td>\n",
" <td>237.0</td>\n",
" <td>28.0</td>\n",
" <td>20.0</td>\n",
" <td>Sherlock Holmes and the Case of the Hound of t...</td>\n",
" <td>9781596792500 Sherlock Holmes and Dr. Watson t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4942</th>\n",
" <td>9781599900056</td>\n",
" <td>159990005X</td>\n",
" <td>The Drift House</td>\n",
" <td>Dale Peck</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=kbwPY...</td>\n",
" <td>Sent to stay with their uncle in a ship-like h...</td>\n",
" <td>2006.0</td>\n",
" <td>3.64</td>\n",
" <td>437.0</td>\n",
" <td>595.0</td>\n",
" <td>19.0</td>\n",
" <td>The Drift House: The First Voyage</td>\n",
" <td>9781599900056 Sent to stay with their uncle in...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5010</th>\n",
" <td>9781844580514</td>\n",
" <td>1844580512</td>\n",
" <td>Attack of the Jaguar</td>\n",
" <td>M. A. Harvey</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=3HUdt...</td>\n",
" <td>This training manual for operatives of Xtreme ...</td>\n",
" <td>2004.0</td>\n",
" <td>3.40</td>\n",
" <td>125.0</td>\n",
" <td>4.0</td>\n",
" <td>21.0</td>\n",
" <td>Attack of the Jaguar</td>\n",
" <td>9781844580514 This training manual for operati...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5157</th>\n",
" <td>9781932416374</td>\n",
" <td>1932416374</td>\n",
" <td>The Very Persistent Gappers of Frip</td>\n",
" <td>George Saunders;Lane Smith</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=xYJOP...</td>\n",
" <td>A novel set in the seaside village of Frip fol...</td>\n",
" <td>2006.0</td>\n",
" <td>4.11</td>\n",
" <td>84.0</td>\n",
" <td>2317.0</td>\n",
" <td>19.0</td>\n",
" <td>The Very Persistent Gappers of Frip</td>\n",
" <td>9781932416374 A novel set in the seaside villa...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>390 rows × 14 columns</p>\n",
"</div>"
],
"text/plain": [
" isbn13 isbn10 \\\n",
"30 9780006646006 000664600X \n",
"79 9780020442608 0020442602 \n",
"85 9780030547744 0030547741 \n",
"86 9780060000141 0060000147 \n",
"87 9780060001537 0060001534 \n",
"... ... ... \n",
"4845 9781590385814 1590385810 \n",
"4930 9781596792500 1596792507 \n",
"4942 9781599900056 159990005X \n",
"5010 9781844580514 1844580512 \n",
"5157 9781932416374 1932416374 \n",
"\n",
" title \\\n",
"30 Ocean Star Express \n",
"79 The voyage of the Dawn Treader \n",
"85 Where the Red Fern Grows \n",
"86 Poppy's Return \n",
"87 Diary of a Spider \n",
"... ... \n",
"4845 Fablehaven \n",
"4930 Sherlock Holmes and the Case of the Hound of t... \n",
"4942 The Drift House \n",
"5010 Attack of the Jaguar \n",
"5157 The Very Persistent Gappers of Frip \n",
"\n",
" authors categories \\\n",
"30 Mark Haddon;Peter Sutton Juvenile Fiction \n",
"79 Clive Staples Lewis Juvenile Fiction \n",
"85 Wilson Rawls Juvenile Fiction \n",
"86 Avi Juvenile Fiction \n",
"87 Doreen Cronin Juvenile Fiction \n",
"... ... ... \n",
"4845 Brandon Mull Juvenile Fiction \n",
"4930 Arthur Conan Doyle;Malvina G. Vogel Juvenile Fiction \n",
"4942 Dale Peck Juvenile Fiction \n",
"5010 M. A. Harvey Juvenile Fiction \n",
"5157 George Saunders;Lane Smith Juvenile Fiction \n",
"\n",
" thumbnail \\\n",
"30 http://books.google.com/books/content?id=I2QZA... \n",
"79 http://books.google.com/books/content?id=fDD3C... \n",
"85 http://books.google.com/books/content?id=IHpRw... \n",
"86 http://books.google.com/books/content?id=XbcMJ... \n",
"87 http://books.google.com/books/content?id=UWvZo... \n",
"... ... \n",
"4845 http://books.google.com/books/content?id=tbVIP... \n",
"4930 http://books.google.com/books/content?id=EWgWP... \n",
"4942 http://books.google.com/books/content?id=kbwPY... \n",
"5010 http://books.google.com/books/content?id=3HUdt... \n",
"5157 http://books.google.com/books/content?id=xYJOP... \n",
"\n",
" description published_year \\\n",
"30 Joe and his parents are enjoying a summer holi... 2002.0 \n",
"79 The \"Dawn Treader\" is the first ship Narnia ha... 1970.0 \n",
"85 A young boy living in the Ozarks achieves his ... 2000.0 \n",
"86 There's trouble at Gray House, the girlhood ho... 2006.0 \n",
"87 This is the diary ... of a spider. But don't b... 2005.0 \n",
"... ... ... \n",
"4845 When Kendra and Seth go to stay at their grand... 2006.0 \n",
"4930 Sherlock Holmes and Dr. Watson travel to the b... 2005.0 \n",
"4942 Sent to stay with their uncle in a ship-like h... 2006.0 \n",
"5010 This training manual for operatives of Xtreme ... 2004.0 \n",
"5157 A novel set in the seaside village of Frip fol... 2006.0 \n",
"\n",
" average_rating num_pages ratings_count agg_of_book \\\n",
"30 3.50 32.0 1.0 23.0 \n",
"79 4.09 216.0 2869.0 55.0 \n",
"85 4.37 288.0 95.0 25.0 \n",
"86 3.99 256.0 1086.0 19.0 \n",
"87 4.25 40.0 7903.0 20.0 \n",
"... ... ... ... ... \n",
"4845 4.09 351.0 111896.0 19.0 \n",
"4930 4.51 237.0 28.0 20.0 \n",
"4942 3.64 437.0 595.0 19.0 \n",
"5010 3.40 125.0 4.0 21.0 \n",
"5157 4.11 84.0 2317.0 19.0 \n",
"\n",
" title_and_subtitle \\\n",
"30 Ocean Star Express \n",
"79 The voyage of the Dawn Treader \n",
"85 Where the Red Fern Grows: The Story of Two Dog... \n",
"86 Poppy's Return \n",
"87 Diary of a Spider \n",
"... ... \n",
"4845 Fablehaven \n",
"4930 Sherlock Holmes and the Case of the Hound of t... \n",
"4942 The Drift House: The First Voyage \n",
"5010 Attack of the Jaguar \n",
"5157 The Very Persistent Gappers of Frip \n",
"\n",
" tagged_description \n",
"30 9780006646006 Joe and his parents are enjoying... \n",
"79 9780020442608 The \"Dawn Treader\" is the first ... \n",
"85 9780030547744 A young boy living in the Ozarks... \n",
"86 9780060000141 There's trouble at Gray House, t... \n",
"87 9780060001537 This is the diary ... of a spide... \n",
"... ... \n",
"4845 9781590385814 When Kendra and Seth go to stay ... \n",
"4930 9781596792500 Sherlock Holmes and Dr. Watson t... \n",
"4942 9781599900056 Sent to stay with their uncle in... \n",
"5010 9781844580514 This training manual for operati... \n",
"5157 9781932416374 A novel set in the seaside villa... \n",
"\n",
"[390 rows x 14 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books[books[\"categories\"] == \"Juvenile Fiction\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a725550a",
"metadata": {},
"outputs": [],
"source": [
"books[books[\"categories\"] == \"Juvenile Nonfiction\"]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "586c5da4",
"metadata": {},
"outputs": [],
"source": [
"category_mapping = {'Fiction' : \"Fiction\",\n",
" 'Juvenile Fiction': \"Children's Fiction\",\n",
" 'Biography & Autobiography': \"Nonfiction\",\n",
" 'History': \"Nonfiction\",\n",
" 'Literary Criticism': \"Nonfiction\",\n",
" 'Philosophy': \"Nonfiction\",\n",
" 'Religion': \"Nonfiction\",\n",
" 'Comics & Graphic Novels': \"Fiction\",\n",
" 'Drama': \"Fiction\",\n",
" 'Juvenile Nonfiction': \"Children's Nonfiction\",\n",
" 'Science': \"Nonfiction\",\n",
" 'Poetry': \"Fiction\"}\n",
"\n",
"books[\"simple_categories\"] = books[\"categories\"].map(category_mapping)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "62850edd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>isbn10</th>\n",
" <th>title</th>\n",
" <th>authors</th>\n",
" <th>categories</th>\n",
" <th>thumbnail</th>\n",
" <th>description</th>\n",
" <th>published_year</th>\n",
" <th>average_rating</th>\n",
" <th>num_pages</th>\n",
" <th>ratings_count</th>\n",
" <th>agg_of_book</th>\n",
" <th>title_and_subtitle</th>\n",
" <th>tagged_description</th>\n",
" <th>simple_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>9780002005883</td>\n",
" <td>0002005883</td>\n",
" <td>Gilead</td>\n",
" <td>Marilynne Robinson</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=KQZCP...</td>\n",
" <td>A NOVEL THAT READERS and critics have been eag...</td>\n",
" <td>2004.0</td>\n",
" <td>3.85</td>\n",
" <td>247.0</td>\n",
" <td>361.0</td>\n",
" <td>21.0</td>\n",
" <td>Gilead</td>\n",
" <td>9780002005883 A NOVEL THAT READERS and critics...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>9780002261982</td>\n",
" <td>0002261987</td>\n",
" <td>Spider's Web</td>\n",
" <td>Charles Osborne;Agatha Christie</td>\n",
" <td>Detective and mystery stories</td>\n",
" <td>http://books.google.com/books/content?id=gA5GP...</td>\n",
" <td>A new 'Christie for Christmas' -- a full-lengt...</td>\n",
" <td>2000.0</td>\n",
" <td>3.83</td>\n",
" <td>241.0</td>\n",
" <td>5164.0</td>\n",
" <td>25.0</td>\n",
" <td>Spider's Web: A Novel</td>\n",
" <td>9780002261982 A new 'Christie for Christmas' -...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9780006178736</td>\n",
" <td>0006178731</td>\n",
" <td>Rage of angels</td>\n",
" <td>Sidney Sheldon</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=FKo2T...</td>\n",
" <td>A memorable, mesmerizing heroine Jennifer -- b...</td>\n",
" <td>1993.0</td>\n",
" <td>3.93</td>\n",
" <td>512.0</td>\n",
" <td>29532.0</td>\n",
" <td>32.0</td>\n",
" <td>Rage of angels</td>\n",
" <td>9780006178736 A memorable, mesmerizing heroine...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>9780006280897</td>\n",
" <td>0006280897</td>\n",
" <td>The Four Loves</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Christian life</td>\n",
" <td>http://books.google.com/books/content?id=XhQ5X...</td>\n",
" <td>Lewis' work on the nature of love divides love...</td>\n",
" <td>2002.0</td>\n",
" <td>4.15</td>\n",
" <td>170.0</td>\n",
" <td>33684.0</td>\n",
" <td>23.0</td>\n",
" <td>The Four Loves</td>\n",
" <td>9780006280897 Lewis' work on the nature of lov...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>9780006280934</td>\n",
" <td>0006280935</td>\n",
" <td>The Problem of Pain</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Christian life</td>\n",
" <td>http://books.google.com/books/content?id=Kk-uV...</td>\n",
" <td>\"In The Problem of Pain, C.S. Lewis, one of th...</td>\n",
" <td>2002.0</td>\n",
" <td>4.09</td>\n",
" <td>176.0</td>\n",
" <td>37569.0</td>\n",
" <td>23.0</td>\n",
" <td>The Problem of Pain</td>\n",
" <td>9780006280934 \"In The Problem of Pain, C.S. Le...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" isbn13 isbn10 title \\\n",
"0 9780002005883 0002005883 Gilead \n",
"1 9780002261982 0002261987 Spider's Web \n",
"2 9780006178736 0006178731 Rage of angels \n",
"3 9780006280897 0006280897 The Four Loves \n",
"4 9780006280934 0006280935 The Problem of Pain \n",
"\n",
" authors categories \\\n",
"0 Marilynne Robinson Fiction \n",
"1 Charles Osborne;Agatha Christie Detective and mystery stories \n",
"2 Sidney Sheldon Fiction \n",
"3 Clive Staples Lewis Christian life \n",
"4 Clive Staples Lewis Christian life \n",
"\n",
" thumbnail \\\n",
"0 http://books.google.com/books/content?id=KQZCP... \n",
"1 http://books.google.com/books/content?id=gA5GP... \n",
"2 http://books.google.com/books/content?id=FKo2T... \n",
"3 http://books.google.com/books/content?id=XhQ5X... \n",
"4 http://books.google.com/books/content?id=Kk-uV... \n",
"\n",
" description published_year \\\n",
"0 A NOVEL THAT READERS and critics have been eag... 2004.0 \n",
"1 A new 'Christie for Christmas' -- a full-lengt... 2000.0 \n",
"2 A memorable, mesmerizing heroine Jennifer -- b... 1993.0 \n",
"3 Lewis' work on the nature of love divides love... 2002.0 \n",
"4 \"In The Problem of Pain, C.S. Lewis, one of th... 2002.0 \n",
"\n",
" average_rating num_pages ratings_count agg_of_book \\\n",
"0 3.85 247.0 361.0 21.0 \n",
"1 3.83 241.0 5164.0 25.0 \n",
"2 3.93 512.0 29532.0 32.0 \n",
"3 4.15 170.0 33684.0 23.0 \n",
"4 4.09 176.0 37569.0 23.0 \n",
"\n",
" title_and_subtitle tagged_description \\\n",
"0 Gilead 9780002005883 A NOVEL THAT READERS and critics... \n",
"1 Spider's Web: A Novel 9780002261982 A new 'Christie for Christmas' -... \n",
"2 Rage of angels 9780006178736 A memorable, mesmerizing heroine... \n",
"3 The Four Loves 9780006280897 Lewis' work on the nature of lov... \n",
"4 The Problem of Pain 9780006280934 \"In The Problem of Pain, C.S. Le... \n",
"\n",
" simple_categories \n",
"0 Fiction \n",
"1 NaN \n",
"2 Fiction \n",
"3 NaN \n",
"4 NaN "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "807213f2",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>isbn10</th>\n",
" <th>title</th>\n",
" <th>authors</th>\n",
" <th>categories</th>\n",
" <th>thumbnail</th>\n",
" <th>description</th>\n",
" <th>published_year</th>\n",
" <th>average_rating</th>\n",
" <th>num_pages</th>\n",
" <th>ratings_count</th>\n",
" <th>agg_of_book</th>\n",
" <th>title_and_subtitle</th>\n",
" <th>tagged_description</th>\n",
" <th>simple_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>9780002005883</td>\n",
" <td>0002005883</td>\n",
" <td>Gilead</td>\n",
" <td>Marilynne Robinson</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=KQZCP...</td>\n",
" <td>A NOVEL THAT READERS and critics have been eag...</td>\n",
" <td>2004.0</td>\n",
" <td>3.85</td>\n",
" <td>247.0</td>\n",
" <td>361.0</td>\n",
" <td>21.0</td>\n",
" <td>Gilead</td>\n",
" <td>9780002005883 A NOVEL THAT READERS and critics...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9780006178736</td>\n",
" <td>0006178731</td>\n",
" <td>Rage of angels</td>\n",
" <td>Sidney Sheldon</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=FKo2T...</td>\n",
" <td>A memorable, mesmerizing heroine Jennifer -- b...</td>\n",
" <td>1993.0</td>\n",
" <td>3.93</td>\n",
" <td>512.0</td>\n",
" <td>29532.0</td>\n",
" <td>32.0</td>\n",
" <td>Rage of angels</td>\n",
" <td>9780006178736 A memorable, mesmerizing heroine...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>9780006482079</td>\n",
" <td>0006482074</td>\n",
" <td>Warhost of Vastmark</td>\n",
" <td>Janny Wurts</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=uOL0f...</td>\n",
" <td>Tricked once more by his wily half-brother, Ly...</td>\n",
" <td>1995.0</td>\n",
" <td>4.03</td>\n",
" <td>522.0</td>\n",
" <td>2966.0</td>\n",
" <td>30.0</td>\n",
" <td>Warhost of Vastmark</td>\n",
" <td>9780006482079 Tricked once more by his wily ha...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>9780006646006</td>\n",
" <td>000664600X</td>\n",
" <td>Ocean Star Express</td>\n",
" <td>Mark Haddon;Peter Sutton</td>\n",
" <td>Juvenile Fiction</td>\n",
" <td>http://books.google.com/books/content?id=I2QZA...</td>\n",
" <td>Joe and his parents are enjoying a summer holi...</td>\n",
" <td>2002.0</td>\n",
" <td>3.50</td>\n",
" <td>32.0</td>\n",
" <td>1.0</td>\n",
" <td>23.0</td>\n",
" <td>Ocean Star Express</td>\n",
" <td>9780006646006 Joe and his parents are enjoying...</td>\n",
" <td>Children's Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46</th>\n",
" <td>9780007121014</td>\n",
" <td>0007121016</td>\n",
" <td>Taken at the Flood</td>\n",
" <td>Agatha Christie</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=3gWlx...</td>\n",
" <td>A Few Weeks After Marrying An Attractive Young...</td>\n",
" <td>2002.0</td>\n",
" <td>3.71</td>\n",
" <td>352.0</td>\n",
" <td>8852.0</td>\n",
" <td>23.0</td>\n",
" <td>Taken at the Flood</td>\n",
" <td>9780007121014 A Few Weeks After Marrying An At...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5178</th>\n",
" <td>9781933648279</td>\n",
" <td>1933648279</td>\n",
" <td>Night Has a Thousand Eyes</td>\n",
" <td>Cornell Woolrich</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=3Gk6s...</td>\n",
" <td>\"Cornell Woolrich's novels define the essence ...</td>\n",
" <td>2007.0</td>\n",
" <td>3.77</td>\n",
" <td>344.0</td>\n",
" <td>680.0</td>\n",
" <td>18.0</td>\n",
" <td>Night Has a Thousand Eyes</td>\n",
" <td>9781933648279 \"Cornell Woolrich's novels defin...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5188</th>\n",
" <td>9784770028969</td>\n",
" <td>4770028962</td>\n",
" <td>Coin Locker Babies</td>\n",
" <td>村上龍</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=87DJw...</td>\n",
" <td>Rescued from the lockers in which they were le...</td>\n",
" <td>2002.0</td>\n",
" <td>3.75</td>\n",
" <td>393.0</td>\n",
" <td>5560.0</td>\n",
" <td>23.0</td>\n",
" <td>Coin Locker Babies</td>\n",
" <td>9784770028969 Rescued from the lockers in whic...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5189</th>\n",
" <td>9788122200850</td>\n",
" <td>8122200850</td>\n",
" <td>Cry, the Peacock</td>\n",
" <td>Anita Desai</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=_QKwV...</td>\n",
" <td>This book is the story of a young girl obsesse...</td>\n",
" <td>1980.0</td>\n",
" <td>3.22</td>\n",
" <td>218.0</td>\n",
" <td>134.0</td>\n",
" <td>45.0</td>\n",
" <td>Cry, the Peacock</td>\n",
" <td>9788122200850 This book is the story of a youn...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5195</th>\n",
" <td>9788185300535</td>\n",
" <td>8185300534</td>\n",
" <td>I Am that</td>\n",
" <td>Sri Nisargadatta Maharaj;Sudhakar S. Dikshit</td>\n",
" <td>Philosophy</td>\n",
" <td>http://books.google.com/books/content?id=Fv_JP...</td>\n",
" <td>This collection of the timeless teachings of o...</td>\n",
" <td>1999.0</td>\n",
" <td>4.51</td>\n",
" <td>531.0</td>\n",
" <td>104.0</td>\n",
" <td>26.0</td>\n",
" <td>I Am that: Talks with Sri Nisargadatta Maharaj</td>\n",
" <td>9788185300535 This collection of the timeless ...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5196</th>\n",
" <td>9789027712059</td>\n",
" <td>9027712050</td>\n",
" <td>The Berlin Phenomenology</td>\n",
" <td>Georg Wilhelm Friedrich Hegel</td>\n",
" <td>History</td>\n",
" <td>http://books.google.com/books/content?id=Vy7Sk...</td>\n",
" <td>Since the three volume edition ofHegel's Philo...</td>\n",
" <td>1981.0</td>\n",
" <td>0.00</td>\n",
" <td>210.0</td>\n",
" <td>0.0</td>\n",
" <td>44.0</td>\n",
" <td>The Berlin Phenomenology</td>\n",
" <td>9789027712059 Since the three volume edition o...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>3743 rows × 15 columns</p>\n",
"</div>"
],
"text/plain": [
" isbn13 isbn10 title \\\n",
"0 9780002005883 0002005883 Gilead \n",
"2 9780006178736 0006178731 Rage of angels \n",
"8 9780006482079 0006482074 Warhost of Vastmark \n",
"30 9780006646006 000664600X Ocean Star Express \n",
"46 9780007121014 0007121016 Taken at the Flood \n",
"... ... ... ... \n",
"5178 9781933648279 1933648279 Night Has a Thousand Eyes \n",
"5188 9784770028969 4770028962 Coin Locker Babies \n",
"5189 9788122200850 8122200850 Cry, the Peacock \n",
"5195 9788185300535 8185300534 I Am that \n",
"5196 9789027712059 9027712050 The Berlin Phenomenology \n",
"\n",
" authors categories \\\n",
"0 Marilynne Robinson Fiction \n",
"2 Sidney Sheldon Fiction \n",
"8 Janny Wurts Fiction \n",
"30 Mark Haddon;Peter Sutton Juvenile Fiction \n",
"46 Agatha Christie Fiction \n",
"... ... ... \n",
"5178 Cornell Woolrich Fiction \n",
"5188 村上龍 Fiction \n",
"5189 Anita Desai Fiction \n",
"5195 Sri Nisargadatta Maharaj;Sudhakar S. Dikshit Philosophy \n",
"5196 Georg Wilhelm Friedrich Hegel History \n",
"\n",
" thumbnail \\\n",
"0 http://books.google.com/books/content?id=KQZCP... \n",
"2 http://books.google.com/books/content?id=FKo2T... \n",
"8 http://books.google.com/books/content?id=uOL0f... \n",
"30 http://books.google.com/books/content?id=I2QZA... \n",
"46 http://books.google.com/books/content?id=3gWlx... \n",
"... ... \n",
"5178 http://books.google.com/books/content?id=3Gk6s... \n",
"5188 http://books.google.com/books/content?id=87DJw... \n",
"5189 http://books.google.com/books/content?id=_QKwV... \n",
"5195 http://books.google.com/books/content?id=Fv_JP... \n",
"5196 http://books.google.com/books/content?id=Vy7Sk... \n",
"\n",
" description published_year \\\n",
"0 A NOVEL THAT READERS and critics have been eag... 2004.0 \n",
"2 A memorable, mesmerizing heroine Jennifer -- b... 1993.0 \n",
"8 Tricked once more by his wily half-brother, Ly... 1995.0 \n",
"30 Joe and his parents are enjoying a summer holi... 2002.0 \n",
"46 A Few Weeks After Marrying An Attractive Young... 2002.0 \n",
"... ... ... \n",
"5178 \"Cornell Woolrich's novels define the essence ... 2007.0 \n",
"5188 Rescued from the lockers in which they were le... 2002.0 \n",
"5189 This book is the story of a young girl obsesse... 1980.0 \n",
"5195 This collection of the timeless teachings of o... 1999.0 \n",
"5196 Since the three volume edition ofHegel's Philo... 1981.0 \n",
"\n",
" average_rating num_pages ratings_count agg_of_book \\\n",
"0 3.85 247.0 361.0 21.0 \n",
"2 3.93 512.0 29532.0 32.0 \n",
"8 4.03 522.0 2966.0 30.0 \n",
"30 3.50 32.0 1.0 23.0 \n",
"46 3.71 352.0 8852.0 23.0 \n",
"... ... ... ... ... \n",
"5178 3.77 344.0 680.0 18.0 \n",
"5188 3.75 393.0 5560.0 23.0 \n",
"5189 3.22 218.0 134.0 45.0 \n",
"5195 4.51 531.0 104.0 26.0 \n",
"5196 0.00 210.0 0.0 44.0 \n",
"\n",
" title_and_subtitle \\\n",
"0 Gilead \n",
"2 Rage of angels \n",
"8 Warhost of Vastmark \n",
"30 Ocean Star Express \n",
"46 Taken at the Flood \n",
"... ... \n",
"5178 Night Has a Thousand Eyes \n",
"5188 Coin Locker Babies \n",
"5189 Cry, the Peacock \n",
"5195 I Am that: Talks with Sri Nisargadatta Maharaj \n",
"5196 The Berlin Phenomenology \n",
"\n",
" tagged_description simple_categories \n",
"0 9780002005883 A NOVEL THAT READERS and critics... Fiction \n",
"2 9780006178736 A memorable, mesmerizing heroine... Fiction \n",
"8 9780006482079 Tricked once more by his wily ha... Fiction \n",
"30 9780006646006 Joe and his parents are enjoying... Children's Fiction \n",
"46 9780007121014 A Few Weeks After Marrying An At... Fiction \n",
"... ... ... \n",
"5178 9781933648279 \"Cornell Woolrich's novels defin... Fiction \n",
"5188 9784770028969 Rescued from the lockers in whic... Fiction \n",
"5189 9788122200850 This book is the story of a youn... Fiction \n",
"5195 9788185300535 This collection of the timeless ... Nonfiction \n",
"5196 9789027712059 Since the three volume edition o... Nonfiction \n",
"\n",
"[3743 rows x 15 columns]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books[~(books[\"simple_categories\"].isna())]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "87f7e85e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n",
"Device set to use cuda\n"
]
}
],
"source": [
"from transformers import pipeline\n",
"\n",
"fiction_categories = [\"Fiction\", \"Nonfiction\"]\n",
"\n",
"pipe = pipeline(\"zero-shot-classification\",\n",
" model=\"facebook/bart-large-mnli\",\n",
" device=\"cuda\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "de137173",
"metadata": {},
"outputs": [],
"source": [
"sequence = books.loc[books[\"simple_categories\"] == \"Fiction\", \"description\"].reset_index(drop=True)[0]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "1cbd4fe8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sequence': 'A NOVEL THAT READERS and critics have been eagerly anticipating for over a decade, Gilead is an astonishingly imagined story of remarkable lives. John Ames is a preacher, the son of a preacher and the grandson (both maternal and paternal) of preachers. It’s 1956 in Gilead, Iowa, towards the end of the Reverend Ames’s life, and he is absorbed in recording his family’s story, a legacy for the young son he will never see grow up. Haunted by his grandfather’s presence, John tells of the rift between his grandfather and his father: the elder, an angry visionary who fought for the abolitionist cause, and his son, an ardent pacifist. He is troubled, too, by his prodigal namesake, Jack (John Ames) Boughton, his best friend’s lost son who returns to Gilead searching for forgiveness and redemption. Told in John Ames’s joyous, rambling voice that finds beauty, humour and truth in the smallest of life’s details, Gilead is a song of celebration and acceptance of the best and the worst the world has to offer. At its heart is a tale of the sacred bonds between fathers and sons, pitch-perfect in style and story, set to dazzle critics and readers alike.',\n",
" 'labels': ['Fiction', 'Nonfiction'],\n",
" 'scores': [0.8438260555267334, 0.1561739593744278]}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pipe(sequence, fiction_categories)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "70cd6946",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Fiction'"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"import numpy as np\n",
"\n",
"max_index = np.argmax(pipe(sequence, fiction_categories)[\"scores\"])\n",
"max_label = pipe(sequence, fiction_categories)[\"labels\"][max_index]\n",
"max_label"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "39793314",
"metadata": {},
"outputs": [],
"source": [
"def generate_predictions(sequence, categories):\n",
" predictions = pipe(sequence, categories)\n",
" max_index = np.argmax(predictions[\"scores\"])\n",
" max_label = predictions[\"labels\"][max_index]\n",
" return max_label"
]
},
{
"cell_type": "markdown",
"id": "234ccfd7",
"metadata": {},
"source": [
"## Model Evaluation"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "ccd1dac4",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 2%|▏ | 7/300 [00:01<00:50, 5.82it/s]You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset\n",
"100%|██████████| 300/300 [00:32<00:00, 9.35it/s]\n"
]
}
],
"source": [
"from tqdm import tqdm\n",
"\n",
"actual_cats = []\n",
"predicted_cats = []\n",
"\n",
"for i in tqdm(range(0, 300)):\n",
" sequence = books.loc[books[\"simple_categories\"] == \"Fiction\", \"description\"].reset_index(drop=True)[i]\n",
" predicted_cats += [generate_predictions(sequence, fiction_categories)]\n",
" actual_cats += [\"Fiction\"]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "599552d1",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 300/300 [00:33<00:00, 8.86it/s]\n"
]
}
],
"source": [
"for i in tqdm(range(0, 300)):\n",
" sequence = books.loc[books[\"simple_categories\"] == \"Nonfiction\", \"description\"].reset_index(drop=True)[i]\n",
" predicted_cats += [generate_predictions(sequence, fiction_categories)]\n",
" actual_cats += [\"Nonfiction\"]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "42009f86",
"metadata": {},
"outputs": [],
"source": [
"predictions_df = pd.DataFrame({\"actual_categories\": actual_cats, \"predicted_categories\": predicted_cats})"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "0c295afe",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>actual_categories</th>\n",
" <th>predicted_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Fiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Fiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Fiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Fiction</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Fiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>595</th>\n",
" <td>Nonfiction</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>596</th>\n",
" <td>Nonfiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>597</th>\n",
" <td>Nonfiction</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>598</th>\n",
" <td>Nonfiction</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>599</th>\n",
" <td>Nonfiction</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>600 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" actual_categories predicted_categories\n",
"0 Fiction Fiction\n",
"1 Fiction Fiction\n",
"2 Fiction Fiction\n",
"3 Fiction Nonfiction\n",
"4 Fiction Fiction\n",
".. ... ...\n",
"595 Nonfiction Nonfiction\n",
"596 Nonfiction Fiction\n",
"597 Nonfiction Nonfiction\n",
"598 Nonfiction Nonfiction\n",
"599 Nonfiction Fiction\n",
"\n",
"[600 rows x 2 columns]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predictions_df"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "a360f103",
"metadata": {},
"outputs": [],
"source": [
"predictions_df[\"correct_prediction\"] = (\n",
" np.where(predictions_df[\"actual_categories\"] == predictions_df[\"predicted_categories\"], 1, 0)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "e0c46466",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.7783333333333333)"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predictions_df[\"correct_prediction\"].sum() / len(predictions_df)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "4cac9b23",
"metadata": {},
"outputs": [],
"source": [
"isbns = []\n",
"predicted_cats = []\n",
"\n",
"missing_cats = books.loc[books[\"simple_categories\"].isna(), [\"isbn13\", \"description\"]].reset_index(drop=True)"
]
},
{
"cell_type": "markdown",
"id": "68598062",
"metadata": {},
"source": [
"Use the model to predict the categories of the missing categories book base on its description"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "bb8156ba",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1454/1454 [02:34<00:00, 9.39it/s]\n"
]
}
],
"source": [
"for i in tqdm(range(0, len(missing_cats))):\n",
" sequence = missing_cats[\"description\"][i]\n",
" predicted_cats += [generate_predictions(sequence, fiction_categories)]\n",
" isbns += [missing_cats[\"isbn13\"][i]]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "7fda2cf0",
"metadata": {},
"outputs": [],
"source": [
"missing_predicted_df = pd.DataFrame({\"isbn13\": isbns, \"predicted_categories\": predicted_cats})"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "ad7a0c7c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>predicted_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>9780002261982</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>9780006280897</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9780006280934</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>9780006380832</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>9780006470229</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1449</th>\n",
" <td>9788125026600</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1450</th>\n",
" <td>9788171565641</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1451</th>\n",
" <td>9788172235222</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1452</th>\n",
" <td>9788173031014</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1453</th>\n",
" <td>9788179921623</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>1454 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" isbn13 predicted_categories\n",
"0 9780002261982 Fiction\n",
"1 9780006280897 Nonfiction\n",
"2 9780006280934 Nonfiction\n",
"3 9780006380832 Nonfiction\n",
"4 9780006470229 Fiction\n",
"... ... ...\n",
"1449 9788125026600 Nonfiction\n",
"1450 9788171565641 Fiction\n",
"1451 9788172235222 Fiction\n",
"1452 9788173031014 Nonfiction\n",
"1453 9788179921623 Fiction\n",
"\n",
"[1454 rows x 2 columns]"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"missing_predicted_df"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "bdb7e240",
"metadata": {},
"outputs": [],
"source": [
"books = pd.merge(books, missing_predicted_df, on=\"isbn13\", how=\"left\")\n",
"books[\"simple_categories\"] = np.where(books[\"simple_categories\"].isna(), books[\"predicted_categories\"], books[\"simple_categories\"])\n",
"books = books.drop(columns = [\"predicted_categories\"])"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "1f1ec77d",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>isbn10</th>\n",
" <th>title</th>\n",
" <th>authors</th>\n",
" <th>categories</th>\n",
" <th>thumbnail</th>\n",
" <th>description</th>\n",
" <th>published_year</th>\n",
" <th>average_rating</th>\n",
" <th>num_pages</th>\n",
" <th>ratings_count</th>\n",
" <th>agg_of_book</th>\n",
" <th>title_and_subtitle</th>\n",
" <th>tagged_description</th>\n",
" <th>simple_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>9780002005883</td>\n",
" <td>0002005883</td>\n",
" <td>Gilead</td>\n",
" <td>Marilynne Robinson</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=KQZCP...</td>\n",
" <td>A NOVEL THAT READERS and critics have been eag...</td>\n",
" <td>2004.0</td>\n",
" <td>3.85</td>\n",
" <td>247.0</td>\n",
" <td>361.0</td>\n",
" <td>21.0</td>\n",
" <td>Gilead</td>\n",
" <td>9780002005883 A NOVEL THAT READERS and critics...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>9780002261982</td>\n",
" <td>0002261987</td>\n",
" <td>Spider's Web</td>\n",
" <td>Charles Osborne;Agatha Christie</td>\n",
" <td>Detective and mystery stories</td>\n",
" <td>http://books.google.com/books/content?id=gA5GP...</td>\n",
" <td>A new 'Christie for Christmas' -- a full-lengt...</td>\n",
" <td>2000.0</td>\n",
" <td>3.83</td>\n",
" <td>241.0</td>\n",
" <td>5164.0</td>\n",
" <td>25.0</td>\n",
" <td>Spider's Web: A Novel</td>\n",
" <td>9780002261982 A new 'Christie for Christmas' -...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9780006178736</td>\n",
" <td>0006178731</td>\n",
" <td>Rage of angels</td>\n",
" <td>Sidney Sheldon</td>\n",
" <td>Fiction</td>\n",
" <td>http://books.google.com/books/content?id=FKo2T...</td>\n",
" <td>A memorable, mesmerizing heroine Jennifer -- b...</td>\n",
" <td>1993.0</td>\n",
" <td>3.93</td>\n",
" <td>512.0</td>\n",
" <td>29532.0</td>\n",
" <td>32.0</td>\n",
" <td>Rage of angels</td>\n",
" <td>9780006178736 A memorable, mesmerizing heroine...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>9780006280897</td>\n",
" <td>0006280897</td>\n",
" <td>The Four Loves</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Christian life</td>\n",
" <td>http://books.google.com/books/content?id=XhQ5X...</td>\n",
" <td>Lewis' work on the nature of love divides love...</td>\n",
" <td>2002.0</td>\n",
" <td>4.15</td>\n",
" <td>170.0</td>\n",
" <td>33684.0</td>\n",
" <td>23.0</td>\n",
" <td>The Four Loves</td>\n",
" <td>9780006280897 Lewis' work on the nature of lov...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>9780006280934</td>\n",
" <td>0006280935</td>\n",
" <td>The Problem of Pain</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Christian life</td>\n",
" <td>http://books.google.com/books/content?id=Kk-uV...</td>\n",
" <td>\"In The Problem of Pain, C.S. Lewis, one of th...</td>\n",
" <td>2002.0</td>\n",
" <td>4.09</td>\n",
" <td>176.0</td>\n",
" <td>37569.0</td>\n",
" <td>23.0</td>\n",
" <td>The Problem of Pain</td>\n",
" <td>9780006280934 \"In The Problem of Pain, C.S. Le...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5192</th>\n",
" <td>9788172235222</td>\n",
" <td>8172235224</td>\n",
" <td>Mistaken Identity</td>\n",
" <td>Nayantara Sahgal</td>\n",
" <td>Indic fiction (English)</td>\n",
" <td>http://books.google.com/books/content?id=q-tKP...</td>\n",
" <td>On A Train Journey Home To North India After L...</td>\n",
" <td>2003.0</td>\n",
" <td>2.93</td>\n",
" <td>324.0</td>\n",
" <td>0.0</td>\n",
" <td>22.0</td>\n",
" <td>Mistaken Identity</td>\n",
" <td>9788172235222 On A Train Journey Home To North...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5193</th>\n",
" <td>9788173031014</td>\n",
" <td>8173031010</td>\n",
" <td>Journey to the East</td>\n",
" <td>Hermann Hesse</td>\n",
" <td>Adventure stories</td>\n",
" <td>http://books.google.com/books/content?id=rq6JP...</td>\n",
" <td>This book tells the tale of a man who goes on ...</td>\n",
" <td>2002.0</td>\n",
" <td>3.70</td>\n",
" <td>175.0</td>\n",
" <td>24.0</td>\n",
" <td>23.0</td>\n",
" <td>Journey to the East</td>\n",
" <td>9788173031014 This book tells the tale of a ma...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5194</th>\n",
" <td>9788179921623</td>\n",
" <td>817992162X</td>\n",
" <td>The Monk Who Sold His Ferrari: A Fable About F...</td>\n",
" <td>Robin Sharma</td>\n",
" <td>Health & Fitness</td>\n",
" <td>http://books.google.com/books/content?id=c_7mf...</td>\n",
" <td>Wisdom to Create a Life of Passion, Purpose, a...</td>\n",
" <td>2003.0</td>\n",
" <td>3.82</td>\n",
" <td>198.0</td>\n",
" <td>1568.0</td>\n",
" <td>22.0</td>\n",
" <td>The Monk Who Sold His Ferrari: A Fable About F...</td>\n",
" <td>9788179921623 Wisdom to Create a Life of Passi...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5195</th>\n",
" <td>9788185300535</td>\n",
" <td>8185300534</td>\n",
" <td>I Am that</td>\n",
" <td>Sri Nisargadatta Maharaj;Sudhakar S. Dikshit</td>\n",
" <td>Philosophy</td>\n",
" <td>http://books.google.com/books/content?id=Fv_JP...</td>\n",
" <td>This collection of the timeless teachings of o...</td>\n",
" <td>1999.0</td>\n",
" <td>4.51</td>\n",
" <td>531.0</td>\n",
" <td>104.0</td>\n",
" <td>26.0</td>\n",
" <td>I Am that: Talks with Sri Nisargadatta Maharaj</td>\n",
" <td>9788185300535 This collection of the timeless ...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5196</th>\n",
" <td>9789027712059</td>\n",
" <td>9027712050</td>\n",
" <td>The Berlin Phenomenology</td>\n",
" <td>Georg Wilhelm Friedrich Hegel</td>\n",
" <td>History</td>\n",
" <td>http://books.google.com/books/content?id=Vy7Sk...</td>\n",
" <td>Since the three volume edition ofHegel's Philo...</td>\n",
" <td>1981.0</td>\n",
" <td>0.00</td>\n",
" <td>210.0</td>\n",
" <td>0.0</td>\n",
" <td>44.0</td>\n",
" <td>The Berlin Phenomenology</td>\n",
" <td>9789027712059 Since the three volume edition o...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5197 rows × 15 columns</p>\n",
"</div>"
],
"text/plain": [
" isbn13 isbn10 \\\n",
"0 9780002005883 0002005883 \n",
"1 9780002261982 0002261987 \n",
"2 9780006178736 0006178731 \n",
"3 9780006280897 0006280897 \n",
"4 9780006280934 0006280935 \n",
"... ... ... \n",
"5192 9788172235222 8172235224 \n",
"5193 9788173031014 8173031010 \n",
"5194 9788179921623 817992162X \n",
"5195 9788185300535 8185300534 \n",
"5196 9789027712059 9027712050 \n",
"\n",
" title \\\n",
"0 Gilead \n",
"1 Spider's Web \n",
"2 Rage of angels \n",
"3 The Four Loves \n",
"4 The Problem of Pain \n",
"... ... \n",
"5192 Mistaken Identity \n",
"5193 Journey to the East \n",
"5194 The Monk Who Sold His Ferrari: A Fable About F... \n",
"5195 I Am that \n",
"5196 The Berlin Phenomenology \n",
"\n",
" authors \\\n",
"0 Marilynne Robinson \n",
"1 Charles Osborne;Agatha Christie \n",
"2 Sidney Sheldon \n",
"3 Clive Staples Lewis \n",
"4 Clive Staples Lewis \n",
"... ... \n",
"5192 Nayantara Sahgal \n",
"5193 Hermann Hesse \n",
"5194 Robin Sharma \n",
"5195 Sri Nisargadatta Maharaj;Sudhakar S. Dikshit \n",
"5196 Georg Wilhelm Friedrich Hegel \n",
"\n",
" categories \\\n",
"0 Fiction \n",
"1 Detective and mystery stories \n",
"2 Fiction \n",
"3 Christian life \n",
"4 Christian life \n",
"... ... \n",
"5192 Indic fiction (English) \n",
"5193 Adventure stories \n",
"5194 Health & Fitness \n",
"5195 Philosophy \n",
"5196 History \n",
"\n",
" thumbnail \\\n",
"0 http://books.google.com/books/content?id=KQZCP... \n",
"1 http://books.google.com/books/content?id=gA5GP... \n",
"2 http://books.google.com/books/content?id=FKo2T... \n",
"3 http://books.google.com/books/content?id=XhQ5X... \n",
"4 http://books.google.com/books/content?id=Kk-uV... \n",
"... ... \n",
"5192 http://books.google.com/books/content?id=q-tKP... \n",
"5193 http://books.google.com/books/content?id=rq6JP... \n",
"5194 http://books.google.com/books/content?id=c_7mf... \n",
"5195 http://books.google.com/books/content?id=Fv_JP... \n",
"5196 http://books.google.com/books/content?id=Vy7Sk... \n",
"\n",
" description published_year \\\n",
"0 A NOVEL THAT READERS and critics have been eag... 2004.0 \n",
"1 A new 'Christie for Christmas' -- a full-lengt... 2000.0 \n",
"2 A memorable, mesmerizing heroine Jennifer -- b... 1993.0 \n",
"3 Lewis' work on the nature of love divides love... 2002.0 \n",
"4 \"In The Problem of Pain, C.S. Lewis, one of th... 2002.0 \n",
"... ... ... \n",
"5192 On A Train Journey Home To North India After L... 2003.0 \n",
"5193 This book tells the tale of a man who goes on ... 2002.0 \n",
"5194 Wisdom to Create a Life of Passion, Purpose, a... 2003.0 \n",
"5195 This collection of the timeless teachings of o... 1999.0 \n",
"5196 Since the three volume edition ofHegel's Philo... 1981.0 \n",
"\n",
" average_rating num_pages ratings_count agg_of_book \\\n",
"0 3.85 247.0 361.0 21.0 \n",
"1 3.83 241.0 5164.0 25.0 \n",
"2 3.93 512.0 29532.0 32.0 \n",
"3 4.15 170.0 33684.0 23.0 \n",
"4 4.09 176.0 37569.0 23.0 \n",
"... ... ... ... ... \n",
"5192 2.93 324.0 0.0 22.0 \n",
"5193 3.70 175.0 24.0 23.0 \n",
"5194 3.82 198.0 1568.0 22.0 \n",
"5195 4.51 531.0 104.0 26.0 \n",
"5196 0.00 210.0 0.0 44.0 \n",
"\n",
" title_and_subtitle \\\n",
"0 Gilead \n",
"1 Spider's Web: A Novel \n",
"2 Rage of angels \n",
"3 The Four Loves \n",
"4 The Problem of Pain \n",
"... ... \n",
"5192 Mistaken Identity \n",
"5193 Journey to the East \n",
"5194 The Monk Who Sold His Ferrari: A Fable About F... \n",
"5195 I Am that: Talks with Sri Nisargadatta Maharaj \n",
"5196 The Berlin Phenomenology \n",
"\n",
" tagged_description simple_categories \n",
"0 9780002005883 A NOVEL THAT READERS and critics... Fiction \n",
"1 9780002261982 A new 'Christie for Christmas' -... Fiction \n",
"2 9780006178736 A memorable, mesmerizing heroine... Fiction \n",
"3 9780006280897 Lewis' work on the nature of lov... Nonfiction \n",
"4 9780006280934 \"In The Problem of Pain, C.S. Le... Nonfiction \n",
"... ... ... \n",
"5192 9788172235222 On A Train Journey Home To North... Fiction \n",
"5193 9788173031014 This book tells the tale of a ma... Nonfiction \n",
"5194 9788179921623 Wisdom to Create a Life of Passi... Fiction \n",
"5195 9788185300535 This collection of the timeless ... Nonfiction \n",
"5196 9789027712059 Since the three volume edition o... Nonfiction \n",
"\n",
"[5197 rows x 15 columns]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "905d016c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>isbn13</th>\n",
" <th>isbn10</th>\n",
" <th>title</th>\n",
" <th>authors</th>\n",
" <th>categories</th>\n",
" <th>thumbnail</th>\n",
" <th>description</th>\n",
" <th>published_year</th>\n",
" <th>average_rating</th>\n",
" <th>num_pages</th>\n",
" <th>ratings_count</th>\n",
" <th>agg_of_book</th>\n",
" <th>title_and_subtitle</th>\n",
" <th>tagged_description</th>\n",
" <th>simple_categories</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>9780006513087</td>\n",
" <td>0006513085</td>\n",
" <td>Gravity</td>\n",
" <td>Tess Gerritsen</td>\n",
" <td>Science fiction</td>\n",
" <td>http://books.google.com/books/content?id=KI66c...</td>\n",
" <td>Emma Watson a research physician has been trai...</td>\n",
" <td>2004.0</td>\n",
" <td>4.04</td>\n",
" <td>342.0</td>\n",
" <td>8024.0</td>\n",
" <td>21.0</td>\n",
" <td>Gravity</td>\n",
" <td>9780006513087 Emma Watson a research physician...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>475</th>\n",
" <td>9780099410355</td>\n",
" <td>0099410354</td>\n",
" <td>Traitor</td>\n",
" <td>Matthew Woodring Stover</td>\n",
" <td>Science fiction</td>\n",
" <td>http://books.google.com/books/content?id=VbICO...</td>\n",
" <td>From the depths of catastrophe, a glimmer of h...</td>\n",
" <td>2002.0</td>\n",
" <td>4.00</td>\n",
" <td>320.0</td>\n",
" <td>6765.0</td>\n",
" <td>23.0</td>\n",
" <td>Traitor</td>\n",
" <td>9780099410355 From the depths of catastrophe, ...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>478</th>\n",
" <td>9780099422341</td>\n",
" <td>0099422344</td>\n",
" <td>Yeats is Dead!</td>\n",
" <td>Joseph O'Connor</td>\n",
" <td>Comedy</td>\n",
" <td>http://books.google.com/books/content?id=DrE3I...</td>\n",
" <td>In aid of Amnesty International, this is a bri...</td>\n",
" <td>2002.0</td>\n",
" <td>3.39</td>\n",
" <td>298.0</td>\n",
" <td>34.0</td>\n",
" <td>23.0</td>\n",
" <td>Yeats is Dead!: A Novel by Fifteen Irish Writers</td>\n",
" <td>9780099422341 In aid of Amnesty International,...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>491</th>\n",
" <td>9780099446729</td>\n",
" <td>0099446723</td>\n",
" <td>Blackwood Farm</td>\n",
" <td>Anne Rice</td>\n",
" <td>Horror</td>\n",
" <td>http://books.google.com/books/content?id=cIn8T...</td>\n",
" <td>Lestat Is Back, Saviour And Demon, Presiding O...</td>\n",
" <td>2003.0</td>\n",
" <td>3.86</td>\n",
" <td>774.0</td>\n",
" <td>26145.0</td>\n",
" <td>22.0</td>\n",
" <td>Blackwood Farm</td>\n",
" <td>9780099446729 Lestat Is Back, Saviour And Demo...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1090</th>\n",
" <td>9780261102422</td>\n",
" <td>0261102427</td>\n",
" <td>The Silmarillion</td>\n",
" <td>John Ronald Reuel Tolkien</td>\n",
" <td>Fantasy</td>\n",
" <td>http://books.google.com/books/content?id=22ePu...</td>\n",
" <td>Tolkien's Silmarillion is the core work of the...</td>\n",
" <td>1999.0</td>\n",
" <td>3.91</td>\n",
" <td>384.0</td>\n",
" <td>253.0</td>\n",
" <td>26.0</td>\n",
" <td>The Silmarillion</td>\n",
" <td>9780261102422 Tolkien's Silmarillion is the co...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1435</th>\n",
" <td>9780340837955</td>\n",
" <td>0340837950</td>\n",
" <td>Stranger in a Strange Land</td>\n",
" <td>Robert A. Heinlein</td>\n",
" <td>Science fiction</td>\n",
" <td>http://books.google.com/books/content?id=ZQhiP...</td>\n",
" <td>Epic, entertaining, Stranger in a Strange Land...</td>\n",
" <td>2005.0</td>\n",
" <td>3.92</td>\n",
" <td>672.0</td>\n",
" <td>563.0</td>\n",
" <td>20.0</td>\n",
" <td>Stranger in a Strange Land</td>\n",
" <td>9780340837955 Epic, entertaining, Stranger in ...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1439</th>\n",
" <td>9780345251220</td>\n",
" <td>0345251229</td>\n",
" <td>Visions from Nowhere</td>\n",
" <td>William Arrow</td>\n",
" <td>Science fiction</td>\n",
" <td>NaN</td>\n",
" <td>The first novel in the series, \"Return to the ...</td>\n",
" <td>1976.0</td>\n",
" <td>3.23</td>\n",
" <td>183.0</td>\n",
" <td>10.0</td>\n",
" <td>49.0</td>\n",
" <td>Visions from Nowhere</td>\n",
" <td>9780345251220 The first novel in the series, \"...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2845</th>\n",
" <td>9780575075597</td>\n",
" <td>0575075597</td>\n",
" <td>Replay</td>\n",
" <td>Ken Grimwood</td>\n",
" <td>Fantasy</td>\n",
" <td>http://books.google.com/books/content?id=9vmNP...</td>\n",
" <td>At forty-three Jeff Winston is tired of his lo...</td>\n",
" <td>2005.0</td>\n",
" <td>4.16</td>\n",
" <td>272.0</td>\n",
" <td>412.0</td>\n",
" <td>20.0</td>\n",
" <td>Replay</td>\n",
" <td>9780575075597 At forty-three Jeff Winston is t...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2860</th>\n",
" <td>9780590254762</td>\n",
" <td>0590254766</td>\n",
" <td>The lion, the witch and the wardrobe</td>\n",
" <td>Clive Staples Lewis</td>\n",
" <td>Fantasy</td>\n",
" <td>NaN</td>\n",
" <td>Four English school children enter the magic l...</td>\n",
" <td>1995.0</td>\n",
" <td>4.21</td>\n",
" <td>189.0</td>\n",
" <td>860.0</td>\n",
" <td>30.0</td>\n",
" <td>The lion, the witch and the wardrobe</td>\n",
" <td>9780590254762 Four English school children ent...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3288</th>\n",
" <td>9780739423851</td>\n",
" <td>0739423851</td>\n",
" <td>Wizard's Castle</td>\n",
" <td>Diana Wynne Jones</td>\n",
" <td>Fantasy</td>\n",
" <td>http://books.google.com/books/content?id=hB7hA...</td>\n",
" <td>Howl's moving castle - Eldest of three sisters...</td>\n",
" <td>2002.0</td>\n",
" <td>4.44</td>\n",
" <td>376.0</td>\n",
" <td>439.0</td>\n",
" <td>23.0</td>\n",
" <td>Wizard's Castle</td>\n",
" <td>9780739423851 Howl's moving castle - Eldest of...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3289</th>\n",
" <td>9780739439708</td>\n",
" <td>0739439707</td>\n",
" <td>Time Quartet</td>\n",
" <td>Madeleine L'Engle</td>\n",
" <td>Science fiction</td>\n",
" <td>NaN</td>\n",
" <td>Blending magic with quantum physics, Madeleine...</td>\n",
" <td>2003.0</td>\n",
" <td>4.35</td>\n",
" <td>646.0</td>\n",
" <td>165.0</td>\n",
" <td>22.0</td>\n",
" <td>Time Quartet</td>\n",
" <td>9780739439708 Blending magic with quantum phys...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3563</th>\n",
" <td>9780760728505</td>\n",
" <td>076072850X</td>\n",
" <td>20,000 Leagues Under the Sea</td>\n",
" <td>Jules Verne</td>\n",
" <td>Science fiction</td>\n",
" <td>NaN</td>\n",
" <td>Retells the adventures of a French professor a...</td>\n",
" <td>2002.0</td>\n",
" <td>3.88</td>\n",
" <td>394.0</td>\n",
" <td>135778.0</td>\n",
" <td>23.0</td>\n",
" <td>20,000 Leagues Under the Sea</td>\n",
" <td>9780760728505 Retells the adventures of a Fren...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4483</th>\n",
" <td>9781416502043</td>\n",
" <td>1416502041</td>\n",
" <td>The Voyage of the Jerle Shannara Trilogy</td>\n",
" <td>Terry Brooks</td>\n",
" <td>Fantasy</td>\n",
" <td>http://books.google.com/books/content?id=jqVsA...</td>\n",
" <td>When the body of a half-drowned elf is found f...</td>\n",
" <td>2004.0</td>\n",
" <td>4.26</td>\n",
" <td>1260.0</td>\n",
" <td>84.0</td>\n",
" <td>21.0</td>\n",
" <td>The Voyage of the Jerle Shannara Trilogy</td>\n",
" <td>9781416502043 When the body of a half-drowned ...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4979</th>\n",
" <td>9781841494081</td>\n",
" <td>1841494089</td>\n",
" <td>The Darkness that Comes Before</td>\n",
" <td>R. Scott Bakker</td>\n",
" <td>Fantasy</td>\n",
" <td>http://books.google.com/books/content?id=BG8qG...</td>\n",
" <td>A score of centuries has passed since the Firs...</td>\n",
" <td>2005.0</td>\n",
" <td>3.79</td>\n",
" <td>638.0</td>\n",
" <td>317.0</td>\n",
" <td>20.0</td>\n",
" <td>The Darkness that Comes Before</td>\n",
" <td>9781841494081 A score of centuries has passed ...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5040</th>\n",
" <td>9781857231359</td>\n",
" <td>185723135X</td>\n",
" <td>Use of Weapons</td>\n",
" <td>Iain Banks</td>\n",
" <td>Science fiction</td>\n",
" <td>NaN</td>\n",
" <td>The man known as Cheradenine Zakalwe was one o...</td>\n",
" <td>1992.0</td>\n",
" <td>4.19</td>\n",
" <td>411.0</td>\n",
" <td>30779.0</td>\n",
" <td>33.0</td>\n",
" <td>Use of Weapons</td>\n",
" <td>9781857231359 The man known as Cheradenine Zak...</td>\n",
" <td>Nonfiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5057</th>\n",
" <td>9781857989342</td>\n",
" <td>1857989341</td>\n",
" <td>The Gods Themselves</td>\n",
" <td>Isaac Asimov</td>\n",
" <td>Science fiction</td>\n",
" <td>http://books.google.com/books/content?id=8ClIP...</td>\n",
" <td>In the year 2100, mankind on Earth, settlers i...</td>\n",
" <td>2000.0</td>\n",
" <td>4.09</td>\n",
" <td>288.0</td>\n",
" <td>41304.0</td>\n",
" <td>25.0</td>\n",
" <td>The Gods Themselves</td>\n",
" <td>9781857989342 In the year 2100, mankind on Ear...</td>\n",
" <td>Fiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" isbn13 isbn10 title \\\n",
"24 9780006513087 0006513085 Gravity \n",
"475 9780099410355 0099410354 Traitor \n",
"478 9780099422341 0099422344 Yeats is Dead! \n",
"491 9780099446729 0099446723 Blackwood Farm \n",
"1090 9780261102422 0261102427 The Silmarillion \n",
"1435 9780340837955 0340837950 Stranger in a Strange Land \n",
"1439 9780345251220 0345251229 Visions from Nowhere \n",
"2845 9780575075597 0575075597 Replay \n",
"2860 9780590254762 0590254766 The lion, the witch and the wardrobe \n",
"3288 9780739423851 0739423851 Wizard's Castle \n",
"3289 9780739439708 0739439707 Time Quartet \n",
"3563 9780760728505 076072850X 20,000 Leagues Under the Sea \n",
"4483 9781416502043 1416502041 The Voyage of the Jerle Shannara Trilogy \n",
"4979 9781841494081 1841494089 The Darkness that Comes Before \n",
"5040 9781857231359 185723135X Use of Weapons \n",
"5057 9781857989342 1857989341 The Gods Themselves \n",
"\n",
" authors categories \\\n",
"24 Tess Gerritsen Science fiction \n",
"475 Matthew Woodring Stover Science fiction \n",
"478 Joseph O'Connor Comedy \n",
"491 Anne Rice Horror \n",
"1090 John Ronald Reuel Tolkien Fantasy \n",
"1435 Robert A. Heinlein Science fiction \n",
"1439 William Arrow Science fiction \n",
"2845 Ken Grimwood Fantasy \n",
"2860 Clive Staples Lewis Fantasy \n",
"3288 Diana Wynne Jones Fantasy \n",
"3289 Madeleine L'Engle Science fiction \n",
"3563 Jules Verne Science fiction \n",
"4483 Terry Brooks Fantasy \n",
"4979 R. Scott Bakker Fantasy \n",
"5040 Iain Banks Science fiction \n",
"5057 Isaac Asimov Science fiction \n",
"\n",
" thumbnail \\\n",
"24 http://books.google.com/books/content?id=KI66c... \n",
"475 http://books.google.com/books/content?id=VbICO... \n",
"478 http://books.google.com/books/content?id=DrE3I... \n",
"491 http://books.google.com/books/content?id=cIn8T... \n",
"1090 http://books.google.com/books/content?id=22ePu... \n",
"1435 http://books.google.com/books/content?id=ZQhiP... \n",
"1439 NaN \n",
"2845 http://books.google.com/books/content?id=9vmNP... \n",
"2860 NaN \n",
"3288 http://books.google.com/books/content?id=hB7hA... \n",
"3289 NaN \n",
"3563 NaN \n",
"4483 http://books.google.com/books/content?id=jqVsA... \n",
"4979 http://books.google.com/books/content?id=BG8qG... \n",
"5040 NaN \n",
"5057 http://books.google.com/books/content?id=8ClIP... \n",
"\n",
" description published_year \\\n",
"24 Emma Watson a research physician has been trai... 2004.0 \n",
"475 From the depths of catastrophe, a glimmer of h... 2002.0 \n",
"478 In aid of Amnesty International, this is a bri... 2002.0 \n",
"491 Lestat Is Back, Saviour And Demon, Presiding O... 2003.0 \n",
"1090 Tolkien's Silmarillion is the core work of the... 1999.0 \n",
"1435 Epic, entertaining, Stranger in a Strange Land... 2005.0 \n",
"1439 The first novel in the series, \"Return to the ... 1976.0 \n",
"2845 At forty-three Jeff Winston is tired of his lo... 2005.0 \n",
"2860 Four English school children enter the magic l... 1995.0 \n",
"3288 Howl's moving castle - Eldest of three sisters... 2002.0 \n",
"3289 Blending magic with quantum physics, Madeleine... 2003.0 \n",
"3563 Retells the adventures of a French professor a... 2002.0 \n",
"4483 When the body of a half-drowned elf is found f... 2004.0 \n",
"4979 A score of centuries has passed since the Firs... 2005.0 \n",
"5040 The man known as Cheradenine Zakalwe was one o... 1992.0 \n",
"5057 In the year 2100, mankind on Earth, settlers i... 2000.0 \n",
"\n",
" average_rating num_pages ratings_count agg_of_book \\\n",
"24 4.04 342.0 8024.0 21.0 \n",
"475 4.00 320.0 6765.0 23.0 \n",
"478 3.39 298.0 34.0 23.0 \n",
"491 3.86 774.0 26145.0 22.0 \n",
"1090 3.91 384.0 253.0 26.0 \n",
"1435 3.92 672.0 563.0 20.0 \n",
"1439 3.23 183.0 10.0 49.0 \n",
"2845 4.16 272.0 412.0 20.0 \n",
"2860 4.21 189.0 860.0 30.0 \n",
"3288 4.44 376.0 439.0 23.0 \n",
"3289 4.35 646.0 165.0 22.0 \n",
"3563 3.88 394.0 135778.0 23.0 \n",
"4483 4.26 1260.0 84.0 21.0 \n",
"4979 3.79 638.0 317.0 20.0 \n",
"5040 4.19 411.0 30779.0 33.0 \n",
"5057 4.09 288.0 41304.0 25.0 \n",
"\n",
" title_and_subtitle \\\n",
"24 Gravity \n",
"475 Traitor \n",
"478 Yeats is Dead!: A Novel by Fifteen Irish Writers \n",
"491 Blackwood Farm \n",
"1090 The Silmarillion \n",
"1435 Stranger in a Strange Land \n",
"1439 Visions from Nowhere \n",
"2845 Replay \n",
"2860 The lion, the witch and the wardrobe \n",
"3288 Wizard's Castle \n",
"3289 Time Quartet \n",
"3563 20,000 Leagues Under the Sea \n",
"4483 The Voyage of the Jerle Shannara Trilogy \n",
"4979 The Darkness that Comes Before \n",
"5040 Use of Weapons \n",
"5057 The Gods Themselves \n",
"\n",
" tagged_description simple_categories \n",
"24 9780006513087 Emma Watson a research physician... Nonfiction \n",
"475 9780099410355 From the depths of catastrophe, ... Fiction \n",
"478 9780099422341 In aid of Amnesty International,... Fiction \n",
"491 9780099446729 Lestat Is Back, Saviour And Demo... Fiction \n",
"1090 9780261102422 Tolkien's Silmarillion is the co... Fiction \n",
"1435 9780340837955 Epic, entertaining, Stranger in ... Fiction \n",
"1439 9780345251220 The first novel in the series, \"... Fiction \n",
"2845 9780575075597 At forty-three Jeff Winston is t... Fiction \n",
"2860 9780590254762 Four English school children ent... Nonfiction \n",
"3288 9780739423851 Howl's moving castle - Eldest of... Fiction \n",
"3289 9780739439708 Blending magic with quantum phys... Fiction \n",
"3563 9780760728505 Retells the adventures of a Fren... Fiction \n",
"4483 9781416502043 When the body of a half-drowned ... Fiction \n",
"4979 9781841494081 A score of centuries has passed ... Nonfiction \n",
"5040 9781857231359 The man known as Cheradenine Zak... Nonfiction \n",
"5057 9781857989342 In the year 2100, mankind on Ear... Fiction "
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"books[books[\"categories\"].str.lower().isin([\n",
" \"romance\",\n",
" \"science fiction\",\n",
" \"scifi\",\n",
" \"fantasy\",\n",
" \"horror\",\n",
" \"mystery\",\n",
" \"thriller\",\n",
" \"comedy\",\n",
" \"crime\",\n",
" \"historical\"\n",
"])]"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "df5056dd",
"metadata": {},
"outputs": [],
"source": [
"books.to_csv(\"books_with_categories.csv\", index=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "books_env",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|