stats and data ['stats', 'data'] Cuddly Bay
I used all of my cuddlies to make a dataset!
About Cuddly Bay
I measured the width and height of my cuddlies. I weighed them and I wrote the hex and the name of the colour. Then I wrote it all down on paper and then copied it to a spreadsheet.
Then we exported it to a CSV file, and we loaded it into python using the pandas package.
import pandas as pd
data = pd.read_csv("data.csv")
I checked that the data was working by loading the first 5 lines.
data.head(5)
Name | Height | Width | Weight | Colour | Hex | |
---|---|---|---|---|---|---|
0 | Tyson | 20 | 13 | 113 | Blue | 0B1D3C |
1 | Deer | 20 | 24 | 172 | Red | FE2D4F |
2 | Sun | 13 | 33 | 216 | Yellow | E1DD73 |
3 | Donald | 11 | 9 | 33 | White | EFF2F6 |
4 | Shin | 13 | 9 | 22 | Brown | D69D61 |
We then checked how many rows and colums there were.
data.shape
(68, 6)
I wanted to see all the cuddlies that weighed above 100g.
data[data["Weight"] > 100].sort_values("Weight", ascending=False)
Name | Height | Width | Weight | Colour | Hex | |
---|---|---|---|---|---|---|
27 | Pickachu | 44 | 26 | 546 | Yellow | EDED6D |
39 | Yoshi | 32 | 15 | 485 | Green | 87D04F |
20 | Tinsel | 37 | 29 | 401 | Blue | 0D2D73 |
38 | N Bear | 39 | 25 | 368 | Brown | D0A17A |
26 | Cat-O-Melon | 50 | 20 | 362 | Red | FE1765 |
44 | Elsear | 41 | 18 | 336 | Orange | FDCC93 |
28 | Bob | 42 | 30 | 320 | Green | 74C344 |
29 | Oshawat | 26 | 21 | 290 | White | E2EAE5 |
11 | Habwig | 38 | 20 | 250 | White | E7EBF1 |
2 | Sun | 13 | 33 | 216 | Yellow | E1DD73 |
37 | Fart Melon | 20 | 18 | 215 | Red | E46C7C |
41 | Les Deglingos | 32 | 16 | 205 | Pink | DO4378 |
31 | Lemon | 19 | 15 | 191 | Yellow | DAD283 |
12 | Pumpki | 14 | 18 | 187 | Brown | DB9294 |
35 | Sami | 14 | 13 | 175 | Orange | B22F12 |
1 | Deer | 20 | 24 | 172 | Red | FE2D4F |
54 | Bunnys | 30 | 20 | 155 | Brown | B4A997 |
55 | Rowlet | 18 | 16 | 151 | Brown | DBB482 |
24 | Boy Dog | 20 | 12 | 143 | Gray | 656965 |
58 | Chabisu | 23 | 20 | 143 | Brown | CE9E67 |
64 | Togipi | 17 | 16 | 121 | White | EBEAE0 |
32 | Soy | 19 | 15 | 120 | Gray | 505758 |
43 | Girl Dog | 10 | 14 | 119 | Brown | BFA372 |
0 | Tyson | 20 | 13 | 113 | Blue | 0B1D3C |
19 | Bambino | 15 | 15 | 110 | Pink | FCA6A3 |
I wanted to see all the cuddlies that were taller than 40cm.
data[data["Height"] > 40]
Name | Height | Width | Weight | Colour | Hex | |
---|---|---|---|---|---|---|
26 | Cat-O-Melon | 50 | 20 | 362 | Red | FE1765 |
27 | Pickachu | 44 | 26 | 546 | Yellow | EDED6D |
28 | Bob | 42 | 30 | 320 | Green | 74C344 |
44 | Elsear | 41 | 18 | 336 | Orange | FDCC93 |
I wanted to see the heights of my cuddlies in a bar chart. This is a histogram, I haven't learnt about these yet.
It looks like my cuddlies average around 13cm tall.
data["Height"].hist();
I wanted to see all the weights of my cuddlies in a bar chart.
It looks like my cuddlies average around 30g.
data["Weight"].hist();
I then wanted to see how many of each colour there is.
It looks like most of my cuddlies are brown and white.
data["Colour"].value_counts()
White 11 Brown 11 Green 9 Yellow 8 Orange 8 Pink 6 Blue 5 Red 4 Gray 4 Black 1 Purple 1 Name: Colour, dtype: int64
I then wanted to see the colours in a bar chart.
data["Colour"].value_counts().plot.bar();
We found this function for displaying swatches online.
from IPython.display import HTML, display
def swatches(colors, sep=' ', width=6):
display(HTML(sep.join(
f'<span style="font-family: monospace">{color} <span style="color: #{color}">{chr(9608)*width}</span></span>'
for color in colors
)))
We then used it to display all the hex colours for my cuddlies.
swatches(data["Hex"])