Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Bryan Dobberstein
16,361 PointsSlicing a slice
This isn't a question, rather an observation. In s2v4.py she uses slicing to remove the first line from data_sample. She then calls calculate_sum from s2v3.py on data_sample, which itself uses slicing to remove the first line of what it receives. This results in the first two lines being sliced, resulting in an incorrect average.
Bryan Dobberstein
16,361 PointsIt's in Data Science Basics-Calculating Averages
https://teamtreehouse.com/library/data-science-basics/describing-data/calculate-averages
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsI agree that the header is automatically removed in s2v3.data_sample() as shown at 02:00 in the calculating sums and totals video.
In the next video, the s2v4.find_average() function is defined correctly, but in the call to the function, the argument has the header pre-removed using a [1:] slice as shown at 02:10 in the calculate averages video. At 02:50 in the same video, an option header parameter is added that doesn't remove the header by default. It's clear at 07:55, that the usage of this parameter still causes a second header removal when calculating the first half data average, effectively removing two headers.
Tagging Craig Dennis to make a note for future course update corrections.
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 PointsGood point. Can you tag the video where this is happening?