Published
Edited
Apr 4, 2019
Insert cell
Insert cell
Insert cell
Insert cell
// Load a file locally
viewof text = html`<input type=file * ">`
Insert cell
tweets = d3.json('https://raw.githubusercontent.com/linjac/11.154_pset_files/master/tweets_1.json')
Insert cell
Insert cell
tweetIDs = Object.keys(tweets)
Insert cell
// your code here
tweetsParsed =
{
var df = []
for (var id in tweetIDs){
df.push(tweets[tweetIDs[id]])
}
return df
}
Insert cell
Insert cell
frequency = z.valueCounts(z.getCol("location", tweetsParsed))// get counts for each unique value in column "
Insert cell
tweetsWFreq = z.addCol("frequency", z.deriveCol((r) => frequency[r.location], tweetsParsed), tweetsParsed)
Insert cell
tweetsFreqSort = z.sortByCol("frequency", "desc", tweetsWFreq)
Insert cell
Insert cell
tweetsConsolidate = z.addCol("location_consolidated", z.deriveCol((r) => replace(r.location), tweetsFreqSort), tweetsFreqSort) // add a column with some values for boston replaced with "boston"
Insert cell
bostonFrequency = z.valueCounts(z.getCol("location_consolidated", tweetsConsolidate))// check to see if consolidation worked for boston
Insert cell
plotLocations = { //dataframe to plot
var df = z.dropCol("frequency", tweetsConsolidate)
return z.addCol("frequency", z.deriveCol((r) => bostonFrequency[r.location], tweetsParsed), df)
}
Insert cell
Insert cell
Insert cell
// your code here
tweetsGeoLoc = z.filter(r => r.lat != null, plotLocations)
Insert cell
Insert cell
Insert cell
// Load a file locally
viewof hashtag_text = html`<input type=file * ">`
Insert cell
Insert cell
// your ciode here
Insert cell
Insert cell
// your code here

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more