In [78]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from IPython.display import Image, display
pd.options.display.max_colwidth = 100

In [2]:
dane_star = pd.read_csv('starwars.csv')

In [3]:
dane_star.head(3)


Out[3]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
0 5860 10179 1 Star Wars Ultimate Collector Series 2007 Ultimate Collector's Millennium Falcon 5.0 5197.0 342.49 499.99 NaN NaN http://images.brickset.com/sets/images/10179-1.jpg No No 0
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0
2 4799 10143 1 Star Wars Ultimate Collector Series 2005 Death Star II NaN 3441.0 249.99 269.99 NaN NaN http://images.brickset.com/sets/images/10143-1.jpg No No 0

In [4]:
dane_star.head(5)


Out[4]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
0 5860 10179 1 Star Wars Ultimate Collector Series 2007 Ultimate Collector's Millennium Falcon 5.0 5197.0 342.49 499.99 NaN NaN http://images.brickset.com/sets/images/10179-1.jpg No No 0
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0
2 4799 10143 1 Star Wars Ultimate Collector Series 2005 Death Star II NaN 3441.0 249.99 269.99 NaN NaN http://images.brickset.com/sets/images/10143-1.jpg No No 0
3 23529 75059 1 Star Wars Ultimate Collector Series 2014 Sandcrawler 14.0 3296.0 249.99 299.99 349.99 299.99 http://images.brickset.com/sets/images/75059-1.jpg No No 0
4 8733 10221 1 Star Wars Ultimate Collector Series 2011 Super Star Destroyer 5.0 3152.0 349.99 399.99 499.99 399.99 http://images.brickset.com/sets/images/10221-1.jpg No No 0

In [5]:
dane_star.describe()


Out[5]:
SetID Variant Year Minifigs Pieces UKPrice USPrice CAPrice EUPrice QtyOwned
count 508.000000 508.000000 508.000000 324.000000 473.000000 298.000000 390.000000 182.000000 171.000000 508.0
mean 12127.389764 1.005906 2009.622047 3.783951 390.892178 45.793725 48.701949 74.720495 62.122807 0.0
std 8550.488882 0.076696 5.022127 2.944732 547.262989 51.543902 60.096567 79.878785 66.707473 0.0
min 21.000000 1.000000 1999.000000 1.000000 1.000000 0.000000 0.000000 6.990000 0.000000 0.0
25% 5528.250000 1.000000 2005.000000 2.000000 81.000000 11.990000 10.000000 24.990000 19.990000 0.0
50% 8727.500000 1.000000 2011.000000 3.000000 226.000000 29.990000 29.990000 49.990000 39.990000 0.0
75% 23366.250000 1.000000 2014.000000 5.000000 465.000000 59.990000 53.742500 89.990000 74.990000 0.0
max 25870.000000 2.000000 2016.000000 24.000000 5197.000000 349.990000 499.990000 499.990000 419.990000 0.0

In [22]:
dane_star.sort_values('Minifigs',ascending=False).head()


Out[22]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0
23 5610 7662 1 Star Wars Episode I 2007 Trade Federation MTT 21.0 1330.0 78.29 99.99 NaN NaN http://images.brickset.com/sets/images/7662-1.jpg No No 0
9 22807 10236 1 Star Wars Episode VI 2013 Ewok Village 17.0 1990.0 199.99 249.99 299.99 249.99 http://images.brickset.com/sets/images/10236-1.jpg No No 0
97 24007 75086 1 Star Wars Episode I 2015 Battle Droid Troop Carrier 15.0 565.0 39.99 39.99 49.99 49.99 http://images.brickset.com/sets/images/75086-1.jpg No No 0
3 23529 75059 1 Star Wars Ultimate Collector Series 2014 Sandcrawler 14.0 3296.0 249.99 299.99 349.99 299.99 http://images.brickset.com/sets/images/75059-1.jpg No No 0

In [23]:
dane_star.sort_values('Pieces',ascending=False).head()


Out[23]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
0 5860 10179 1 Star Wars Ultimate Collector Series 2007 Ultimate Collector's Millennium Falcon 5.0 5197.0 342.49 499.99 NaN NaN http://images.brickset.com/sets/images/10179-1.jpg No No 0
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0
2 4799 10143 1 Star Wars Ultimate Collector Series 2005 Death Star II NaN 3441.0 249.99 269.99 NaN NaN http://images.brickset.com/sets/images/10143-1.jpg No No 0
3 23529 75059 1 Star Wars Ultimate Collector Series 2014 Sandcrawler 14.0 3296.0 249.99 299.99 349.99 299.99 http://images.brickset.com/sets/images/75059-1.jpg No No 0
4 8733 10221 1 Star Wars Ultimate Collector Series 2011 Super Star Destroyer 5.0 3152.0 349.99 399.99 499.99 399.99 http://images.brickset.com/sets/images/10221-1.jpg No No 0

In [39]:
dane_star.sort_values('Pieces',ascending=True).head()


Out[39]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
472 25676 30UNIQUE15 1 Star Wars The Force Awakens 2015 Force Friday Commemorative Brick NaN 1.0 NaN NaN NaN NaN http://images.brickset.com/sets/images/30UNIQUE15-1.jpg No No 0
471 8654 4521221 1 Star Wars Minifig Pack 2007 Gold chrome plated C-3PO NaN 1.0 0.0 0.00 NaN NaN http://images.brickset.com/sets/images/4521221-1.jpg No No 0
469 8655 COMCON005 1 Star Wars Miscellaneous 2009 Collectable Display Set 2 3.0 2.0 NaN 49.99 NaN NaN http://images.brickset.com/sets/images/COMCON005-1.jpg No No 0
470 9327 SW117PROMO 1 Star Wars Promotional 2005 Darth Vader (Nürnberg Toy Fair 2005 Exclusive Figure) 1.0 2.0 NaN NaN NaN NaN http://images.brickset.com/sets/images/SW117PROMO-1.jpg No No 0
467 9349 COMCON011 1 Star Wars Miscellaneous 2009 Holo-Brick Archives (SDCC 2009 exclusive) NaN 3.0 NaN NaN NaN NaN NaN No No 0

In [14]:
dane_star.loc[dane_star.Minifigs>20,:]


Out[14]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0
23 5610 7662 1 Star Wars Episode I 2007 Trade Federation MTT 21.0 1330.0 78.29 99.99 NaN NaN http://images.brickset.com/sets/images/7662-1.jpg No No 0

In [55]:
def get_link(setid):
    link = dane_star.loc[dane_star.SetID==setid,'ImageURL'].reset_index(drop=True)[0]
    return link
    #Image(url=link[0])

In [65]:
Image(url=get_link(5860))


Out[65]:

In [64]:
dane_star['USPrice'].max()


Out[64]:
499.99000000000001

In [70]:
dane_star.loc[dane_star['USPrice'] == dane_star['USPrice'].max(),:]


Out[70]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
0 5860 10179 1 Star Wars Ultimate Collector Series 2007 Ultimate Collector's Millennium Falcon 5.0 5197.0 342.49 499.99 NaN NaN http://images.brickset.com/sets/images/10179-1.jpg No No 0

In [73]:
najstarsze = dane_star.loc[dane_star['Year'] == dane_star['Year'].min(),:]

In [74]:
Image(url=get_link(3826))


Out[74]:

In [79]:
for ii, row in najstarsze.iterrows():
    display(Image(url=get_link(row.SetID)))



In [80]:
najmlodsze = dane_star.loc[dane_star['Year'] == dane_star['Year'].max(),:]

In [85]:
for ii, row in najmlodsze.iterrows():
    try:
        display(Image(url=get_link(row.SetID)))
    except ValueError:
         print("Oops!  ")


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-85-4b45ead4d515> in <module>()
      1 for ii, row in najmlodsze.iterrows():
      2     try:
----> 3         display(Image(url=get_link(row.SetID)))
      4     except ValueError:
      5          print("Oops!  ")

/home/stanislaw/anaconda3/lib/python3.6/site-packages/IPython/core/display.py in __init__(self, data, url, filename, format, embed, width, height, retina, unconfined, metadata)
    714             ext = self._find_ext(filename)
    715         elif url is not None:
--> 716             ext = self._find_ext(url)
    717         elif data is None:
    718             raise ValueError("No image data found. Expecting filename, url, or data.")

/home/stanislaw/anaconda3/lib/python3.6/site-packages/IPython/core/display.py in _find_ext(self, s)
    823 
    824     def _find_ext(self, s):
--> 825         return unicode_type(s.split('.')[-1].lower())
    826 
    827 class Video(DisplayObject):

AttributeError: 'float' object has no attribute 'split'

In [87]:
najmlodsze.head(6)


Out[87]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
83 24798 75140 1 Star Wars The Force Awakens 2016 Resistance Troop Transporter NaN 646.0 NaN NaN NaN 69.99 http://images.brickset.com/sets/images/75140-1.jpg No No 0
140 24959 75139 1 Star Wars The Force Awakens 2016 Battle on Takodana NaN 409.0 NaN NaN NaN 59.99 http://images.brickset.com/sets/images/75139-1.jpg No No 0
309 24780 75115 1 Star Wars Buildable Figures 2016 Poe Dameron NaN 102.0 NaN 19.99 NaN NaN http://images.brickset.com/sets/images/75115-1.jpg No No 0
317 24781 75116 1 Star Wars Buildable Figures 2016 Finn NaN 98.0 NaN NaN NaN NaN http://images.brickset.com/sets/images/75116-1.jpg No No 0
335 24782 75117 1 Star Wars Buildable Figures 2016 Kylo Ren NaN 86.0 NaN 24.99 NaN NaN http://images.brickset.com/sets/images/75117-1.jpg No No 0
339 24778 75113 1 Star Wars Buildable Figures 2016 Rey NaN 84.0 NaN 19.99 NaN NaN http://images.brickset.com/sets/images/75113-1.jpg No No 0

In [89]:
najdrozszeEU = dane_star.loc[dane_star['EUPrice'] == dane_star['EUPrice'].max(),:]
najdrozszeEU


Out[89]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
1 6522 10188 1 Star Wars Ultimate Collector Series 2008 Death Star 24.0 3803.0 274.99 399.99 499.99 419.99 http://images.brickset.com/sets/images/10188-1.jpg No No 0

In [94]:
Image(url=get_link(5860))


Out[94]:

In [93]:
najdrozszeUS = dane_star.loc[dane_star['USPrice'] == dane_star['USPrice'].max(),:]
najdrozszeUS


Out[93]:
SetID Number Variant Theme Subtheme Year Name Minifigs Pieces UKPrice USPrice CAPrice EUPrice ImageURL Owned Wanted QtyOwned
0 5860 10179 1 Star Wars Ultimate Collector Series 2007 Ultimate Collector's Millennium Falcon 5.0 5197.0 342.49 499.99 NaN NaN http://images.brickset.com/sets/images/10179-1.jpg No No 0

In [97]:
dane_star['Year'].hist()


Out[97]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f1bedd611d0>

In [103]:
sns.distplot(dane_star['Year'],bins=dane_star['Year'].drop_duplicates().sort_values(),norm_hist=False)


Out[103]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f1bedb55a58>

In [132]:
to_plot_year = dane_star.loc[:,['Year','SetID']].groupby('Year').agg('count').reset_index()
#to_plot_year

In [131]:
g = sns.barplot(y='SetID',x='Year',data=to_plot_year)
plt.xticks(rotation=45)


Out[131]:
(array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
        17]), <a list of 18 Text xticklabel objects>)

In [134]:
stas = dane_star.loc[dane_star['Year'] == 2008,:]

In [135]:
for ii, row in stas.iterrows():
    try:
        display(Image(url=get_link(row.SetID)))
    except ValueError:
         print("Oops!  ")



In [137]:
ant = dane_star.loc[dane_star['Year'] == 2011,:]

In [139]:
for ii, row in ant.iterrows():
    try:
        display(Image(url=get_link(row.SetID)))
    except ValueError:
         print("Oops!  ")



In [ ]: