File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change 720
720
],
721
721
"source" : [
722
722
" # select the first two columns from the origional dataset\n " ,
723
- " population = crime.iloc[:, 0:1]\n " ,
724
- " \n " ,
725
- " # change the index for decades\n " ,
726
- " population.index = (population.index.year//10)*10\n " ,
727
- " \n " ,
728
- " # group the index by decades and selecting the max value from the Population column \n " ,
729
- " population1 = population.groupby(population.index).max()\n " ,
730
- " population1\n " ,
731
- " \n " ,
732
- " # group the dataframe by decades and sum all values, including population\n " ,
733
- " crime = crime.groupby((crime.index.year//10)*10).sum()\n " ,
734
- " \n " ,
735
- " # assing the right population value (max value) to the \n " ,
736
- " crime['Population'] = population1['Population']\n " ,
737
- " crime"
723
+ " crimes = crime.resample('10AS').sum()\n " ,
724
+ " population = crime['Population'].resample('10AS').max()\n " ,
725
+ " crimes['Population'] = population\n " ,
726
+ " crimes"
738
727
]
739
728
},
740
729
{
You can’t perform that action at this time.
0 commit comments