import pandas as pd # dataframe manipulation
import numpy as np # linear algebra

import os
for dirname, _, filenames in os.walk('/books/'):
    for filename in filenames:
        print(os.path.join(dirname, filename))
books=pd.read_csv('AmazonBooks - Sheet1.csv')
books.head()
Name Author User Rating Reviews Price Year Genre
0 10-Day Green Smoothie Cleanse JJ Smith 4.7 17350 8 2016 Non Fiction
1 11/22/63: A Novel Stephen King 4.6 2052 22 2011 Fiction
2 12 Rules for Life: An Antidote to Chaos Jordan B. Peterson 4.7 18979 15 2018 Non Fiction
3 1984 (Signet Classics) George Orwell 4.7 21424 6 2017 Fiction
4 5,000 Awesome Facts (About Everything!) (Natio... National Geographic Kids 4.8 7665 12 2019 Non Fiction
books.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 600 entries, 0 to 599
Data columns (total 7 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   Name         600 non-null    object 
 1   Author       600 non-null    object 
 2   User Rating  600 non-null    float64
 3   Reviews      600 non-null    int64  
 4   Price        600 non-null    int64  
 5   Year         600 non-null    int64  
 6   Genre        600 non-null    object 
dtypes: float64(1), int64(3), object(3)
memory usage: 32.9+ KB
books[books['User Rating']==books['User Rating'].max()]
Name Author User Rating Reviews Price Year Genre
40 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2017 Fiction
41 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2019 Fiction
81 Dog Man and Cat Kid: From the Creator of Capta... Dav Pilkey 4.9 5062 6 2018 Fiction
82 Dog Man: A Tale of Two Kitties: From the Creat... Dav Pilkey 4.9 4786 8 2017 Fiction
83 Dog Man: Brawl of the Wild: From the Creator o... Dav Pilkey 4.9 7235 4 2018 Fiction
... ... ... ... ... ... ... ...
573 The Deep End (Diary of a Wimpy Kid Book 15) Jeff Kinney 4.9 26047 7 2020 Fiction
575 I Love You to the Moon and Back Amelia Hepworth 4.9 24356 1 2020 Fiction
580 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 25321 5 2020 Fiction
582 Magnolia Table, Volume 2 Joanna Gaines 4.9 16515 17 2020 Non Fiction
594 Chicka Chicka Boom Boom Bill Martin Jr. 4.9 20705 4 2020 Fiction

61 rows × 7 columns

books[books['User Rating']==books['User Rating'].max()].count()
Name           61
Author         61
User Rating    61
Reviews        61
Price          61
Year           61
Genre          61
dtype: int64
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(12,4))
sns.barplot(x='Year',y='User Rating',data=books)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ceceabd0>
books[books['User Rating']==books['User Rating'].min()]
Name Author User Rating Reviews Price Year Genre
353 The Casual Vacancy J.K. Rowling 3.3 9372 12 2012 Fiction
books.groupby('Year')['User Rating'].max()
Year
2009    4.8
2010    4.8
2011    4.9
2012    4.9
2013    4.9
2014    4.9
2015    4.9
2016    4.9
2017    4.9
2018    4.9
2019    4.9
2020    4.9
Name: User Rating, dtype: float64
books[books['Reviews']==books['Reviews'].max()]
Name Author User Rating Reviews Price Year Genre
552 Where the Crawdads Sing Delia Owens 4.8 120727 9 2020 Fiction
books[books['Reviews']==books['Reviews'].min()]
Name Author User Rating Reviews Price Year Genre
78 Divine Soul Mind Body Healing and Transmission... Zhi Gang Sha 4.6 37 6 2009 Non Fiction
books.groupby('Year')['Reviews'].max()
Year
2009     19720
2010     32122
2011     32122
2012     57271
2013     57271
2014     57271
2015     79446
2016     79446
2017     29442
2018     61133
2019     87841
2020    120727
Name: Reviews, dtype: int64
sns.histplot(x='Reviews',data=books,hue='Genre')
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce290f50>
sns.displot(x=books['User Rating'],kde=True)
<seaborn.axisgrid.FacetGrid at 0x7f87ceab3ad0>
sns.boxplot(x='Year',y='User Rating',data=books)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce7acc90>
sns.pointplot(x="Year", y="User Rating", hue="Genre", data=books, alpha=.3)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce997cd0>
sns.lineplot(x="Year", y="User Rating", hue="Genre", data=books, alpha=.3)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce505750>
books[books['Price']==books['Price'].max()]
Name Author User Rating Reviews Price Year Genre
69 Diagnostic and Statistical Manual of Mental Di... American Psychiatric Association 4.5 6679 105 2013 Non Fiction
70 Diagnostic and Statistical Manual of Mental Di... American Psychiatric Association 4.5 6679 105 2014 Non Fiction
sns.histplot(x='Price',data=books,kde=True,color='blue')
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce86a510>
sns.displot(x=books['Price'], hue=books['Genre'], kind="kde", fill=True)
<seaborn.axisgrid.FacetGrid at 0x7f87cde27710>
sns.pointplot(x="Year", y="Price", hue="Genre", data=books, alpha=.3)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce33b1d0>
sns.countplot(x='Genre',data=books)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce8d8810>
df=books[books['Genre']=='Fiction']
df[df['Price']==df['Price'].max()]
Name Author User Rating Reviews Price Year Genre
473 The Twilight Saga Collection Stephenie Meyer 4.7 3801 82 2009 Fiction
df=books[books['Genre']=='Non Fiction']
df[df['Price']==df['Price'].max()]
Name Author User Rating Reviews Price Year Genre
69 Diagnostic and Statistical Manual of Mental Di... American Psychiatric Association 4.5 6679 105 2013 Non Fiction
70 Diagnostic and Statistical Manual of Mental Di... American Psychiatric Association 4.5 6679 105 2014 Non Fiction
df=books[books['Genre']=='Fiction']
df[df['User Rating']==df['User Rating'].max()]
Name Author User Rating Reviews Price Year Genre
40 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2017 Fiction
41 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 14344 5 2019 Fiction
81 Dog Man and Cat Kid: From the Creator of Capta... Dav Pilkey 4.9 5062 6 2018 Fiction
82 Dog Man: A Tale of Two Kitties: From the Creat... Dav Pilkey 4.9 4786 8 2017 Fiction
83 Dog Man: Brawl of the Wild: From the Creator o... Dav Pilkey 4.9 7235 4 2018 Fiction
84 Dog Man: Brawl of the Wild: From the Creator o... Dav Pilkey 4.9 7235 4 2019 Fiction
85 Dog Man: Fetch-22: From the Creator of Captain... Dav Pilkey 4.9 12619 8 2019 Fiction
86 Dog Man: For Whom the Ball Rolls: From the Cre... Dav Pilkey 4.9 9089 8 2019 Fiction
87 Dog Man: Lord of the Fleas: From the Creator o... Dav Pilkey 4.9 5470 6 2018 Fiction
146 Goodnight, Goodnight Construction Site (Hardco... Sherri Duskey Rinker 4.9 7038 7 2012 Fiction
147 Goodnight, Goodnight Construction Site (Hardco... Sherri Duskey Rinker 4.9 7038 7 2013 Fiction
153 Harry Potter and the Chamber of Secrets: The I... J.K. Rowling 4.9 19622 30 2016 Fiction
155 Harry Potter and the Goblet of Fire: The Illus... J. K. Rowling 4.9 7758 18 2019 Fiction
156 Harry Potter and the Prisoner of Azkaban: The ... J.K. Rowling 4.9 3146 30 2017 Fiction
157 Harry Potter and the Sorcerer's Stone: The Ill... J.K. Rowling 4.9 10052 22 2016 Fiction
207 Last Week Tonight with John Oliver Presents A ... Jill Twiss 4.9 11881 13 2018 Fiction
219 Little Blue Truck Alice Schertle 4.9 1884 0 2014 Fiction
245 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2012 Fiction
246 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2013 Fiction
247 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2014 Fiction
248 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2015 Fiction
249 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2016 Fiction
250 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2017 Fiction
251 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2018 Fiction
252 Oh, the Places You'll Go! Dr. Seuss 4.9 21834 8 2019 Fiction
288 Rush Revere and the Brave Pilgrims: Time-Trave... Rush Limbaugh 4.9 7150 12 2013 Fiction
289 Rush Revere and the First Patriots: Time-Trave... Rush Limbaugh 4.9 3836 12 2014 Fiction
303 Strange Planet (Strange Planet Series) Nathan W. Pyle 4.9 9382 6 2019 Fiction
420 The Legend of Zelda: Hyrule Historia Patrick Thorpe 4.9 5396 20 2013 Fiction
476 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2013 Fiction
477 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2014 Fiction
478 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2015 Fiction
479 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2016 Fiction
480 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2017 Fiction
481 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2018 Fiction
482 The Very Hungry Caterpillar Eric Carle 4.9 19546 5 2019 Fiction
486 The Wonderful Things You Will Be Emily Winfield Martin 4.9 8842 10 2016 Fiction
487 The Wonderful Things You Will Be Emily Winfield Martin 4.9 8842 10 2017 Fiction
488 The Wonderful Things You Will Be Emily Winfield Martin 4.9 8842 10 2018 Fiction
489 The Wonderful Things You Will Be Emily Winfield Martin 4.9 8842 10 2019 Fiction
545 Wrecking Ball (Diary of a Wimpy Kid Book 14) Jeff Kinney 4.9 9413 8 2019 Fiction
561 Dog Man: Grime and Punishment Dav Pilkey 4.9 31045 6 2020 Fiction
573 The Deep End (Diary of a Wimpy Kid Book 15) Jeff Kinney 4.9 26047 7 2020 Fiction
575 I Love You to the Moon and Back Amelia Hepworth 4.9 24356 1 2020 Fiction
580 Brown Bear, Brown Bear, What Do You See? Bill Martin Jr. 4.9 25321 5 2020 Fiction
594 Chicka Chicka Boom Boom Bill Martin Jr. 4.9 20705 4 2020 Fiction
df=books[books['Genre']=='Non Fiction']
df[df['User Rating']==df['User Rating'].max()]
Name Author User Rating Reviews Price Year Genre
151 Hamilton: The Revolution Lin-Manuel Miranda 4.9 5867 54 2016 Non Fiction
174 Humans of New York : Stories Brandon Stanton 4.9 2812 17 2015 Non Fiction
187 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2011 Non Fiction
188 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2012 Non Fiction
189 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2013 Non Fiction
190 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2014 Non Fiction
191 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2015 Non Fiction
192 Jesus Calling: Enjoying Peace in His Presence ... Sarah Young 4.9 19576 8 2016 Non Fiction
244 Obama: An Intimate Portrait Pete Souza 4.9 3192 22 2017 Non Fiction
431 The Magnolia Story Chip Gaines 4.9 7861 5 2016 Non Fiction
521 Unfreedom of the Press Mark R. Levin 4.9 5956 11 2019 Non Fiction
550 A Promised Land Barack Obama 4.9 83212 23 2020 Non Fiction
562 The Very Hungry Caterpillar Eric Carle 4.9 35965 7 2020 Non Fiction
571 The Boy, the Mole, the Fox and the Horse Charlie Mackesy 4.9 53549 15 2020 Non Fiction
582 Magnolia Table, Volume 2 Joanna Gaines 4.9 16515 17 2020 Non Fiction
df=books[books['Genre']=='Non Fiction']
df[df['Reviews']==df['Reviews'].max()]
Name Author User Rating Reviews Price Year Genre
563 Becoming Michelle Obama 4.8 99498 10 2020 Non Fiction
df=books[books['Genre']=='Fiction']
df[df['Reviews']==df['Reviews'].max()]
Name Author User Rating Reviews Price Year Genre
552 Where the Crawdads Sing Delia Owens 4.8 120727 9 2020 Fiction
sns.displot(x=books['Reviews'], hue=books['Genre'], kind="kde",fill=True)
<seaborn.axisgrid.FacetGrid at 0x7f87cea73cd0>
sns.pointplot(x="Year", y="Reviews", hue="Genre", data=books, alpha=.3)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce6d8fd0>
books['Author'].value_counts()
Jeff Kinney                           13
Gary Chapman                          12
Suzanne Collins                       12
Rick Riordan                          11
American Psychological Association    10
                                      ..
Christopher Paolini                    1
Jon Stewart                            1
 Bill Martin Jr.                       1
Don Miguel Ruiz                        1
Ian K. Smith M.D.                      1
Name: Author, Length: 275, dtype: int64
df=books[books['User Rating']==books['User Rating'].max()]
df['Author'].unique()
array(['Bill Martin Jr.', 'Dav Pilkey', 'Sherri Duskey Rinker',
       'Lin-Manuel Miranda', 'J.K. Rowling', 'J. K. Rowling',
       'Brandon Stanton', 'Sarah Young', 'Jill Twiss', 'Alice Schertle',
       'Pete Souza', 'Dr. Seuss', 'Rush Limbaugh', 'Nathan W. Pyle',
       'Patrick Thorpe', 'Chip Gaines', 'Eric Carle',
       'Emily Winfield Martin', 'Mark R. Levin', 'Jeff Kinney',
       'Barack Obama', 'Charlie Mackesy', 'Amelia Hepworth',
       ' Bill Martin Jr.', 'Joanna Gaines'], dtype=object)
sns.stripplot(x="Genre", y="User Rating", data=books)
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce3b5210>
sns.heatmap(books.corr(),annot=True,cmap='magma')
<matplotlib.axes._subplots.AxesSubplot at 0x7f87ce2ff350>
sns.clustermap(books.corr(),annot=True,cmap='magma')
<seaborn.matrix.ClusterGrid at 0x7f87ce4472d0>
sns.pairplot(books)
<seaborn.axisgrid.PairGrid at 0x7f87cdf55590>
books.head()
Name Author User Rating Reviews Price Year Genre
0 10-Day Green Smoothie Cleanse JJ Smith 4.7 17350 8 2016 Non Fiction
1 11/22/63: A Novel Stephen King 4.6 2052 22 2011 Fiction
2 12 Rules for Life: An Antidote to Chaos Jordan B. Peterson 4.7 18979 15 2018 Non Fiction
3 1984 (Signet Classics) George Orwell 4.7 21424 6 2017 Fiction
4 5,000 Awesome Facts (About Everything!) (Natio... National Geographic Kids 4.8 7665 12 2019 Non Fiction
sns.lmplot(x='Price',y='Year',data=books,hue='Genre')
<seaborn.axisgrid.FacetGrid at 0x7f87bde172d0>