dlab-berkeley / Python-Web-Scraping-Legacy

D-Lab's 3 hour introduction to web scraping in Python. Learn how to use APIs and scrape data from websites using the New York Times API and BeautifulSoup in Python.
7 stars 3 forks source link

Additional text for "Sentiment Over the Course of the Campaign" #22

Open tomvannuenen opened 2 years ago

tomvannuenen commented 2 years ago

We might want to add some text explaining .resample(). Suggestion:

Next, we'll calculate daily and weekly averages using the .resample() method, which allows us to resample a time series. This method is pretty nifty: in this case, we use it in conjunction with mean() to get the average sentiment when grouping data points by day or week!

Tip: If you want some better intuition of how .resample() works, have a look at what sentiment_ts.resample("d") yields on its own!