Working in Jupyter with Pandas DataSeries I have a dataset with the following lines:
color: white engineType: diesel make: Ford manufacturingYear: 2004 accidentCount: 123
What I need to do is build accident counting charts (y axis) by year of production (x axis) for all color permutations / engineType / make. Any ideas how to do this?
To speed things up, I have this initial setup:
import numpy as np import pandas as pd from pandas import DataFrame, Series import random colors = ['white', 'black','silver'] engineTypes = ['diesel', 'petrol'] makes = ['ford', 'mazda', 'subaru'] years = range(2000,2005) rowCount = 100 def randomEl(data): rand_items = [data[random.randrange(len(data))] for item in range(rowCount)] return rand_items df = DataFrame({ 'color': Series(randomEl(colors)), 'engineType': Series(randomEl(engineTypes)), 'make': Series(randomEl(makes)), 'year': Series(randomEl(years)), 'accidents': Series([int(1000*random.random()) for i in range(rowCount)]) })
source share