Skip to content

Instantly share code, notes, and snippets.

@hugobowne
hugobowne / df_profiler.py
Created March 2, 2022 00:31
Generates rapid, exploratory dataframe reports
import pandas as pd
import pandas_profiling
# Create small df
data = {"name": ["Hugo", "Ville"], "city": ["Sydney", "SF"]}
df = pd.DataFrame(data)
# Create report and save to file
profile = pandas_profiling.ProfileReport(df)
profile.to_file("df_report.html")
@hugobowne
hugobowne / scheme.py
Last active December 30, 2023 04:36
Dave Beazley had us implement a mini-scheme like interpreter in Python today: this is what we came up with.
# scheme.py
#
# Challenge: Can you implement a mini-scheme interpreter (program that's running another program) capable of
# executing the following code (now at bottom of file):
def seval(sexp, env):
if isinstance(sexp, (int, float)):
return sexp
elif isinstance(sexp, str): #Symbols
return env[sexp] #Evaluate symbol names in the 'env'
@hugobowne
hugobowne / tweet_listener.py
Last active October 6, 2023 18:48
NOTE: this code is for a previous version of the Twitter API and I will not be updating in the near future. If someone else would like to, I'd welcome that! Feel free to ping me. END NOTE. Here I define a Tweet listener that creates a file called 'tweets.txt', collects streaming tweets as .jsons and writes them to the file 'tweets.txt'; once 100…
class MyStreamListener(tweepy.StreamListener):
def __init__(self, api=None):
super(MyStreamListener, self).__init__()
self.num_tweets = 0
self.file = open("tweets.txt", "w")
def on_status(self, status):
tweet = status._json
self.file.write( json.dumps(tweet) + '\n' )
self.num_tweets += 1
@hugobowne
hugobowne / README.md
Last active May 22, 2020 23:34
Civic Impact through Data Visualization: Exercise 1

Join the chat at https://gitter.im/Jay-Oh-eN/data-scientists-guide-apache-spark

These are the materials for my workshop on creating interactive data visualizations with D3! We will be using the following two tools to works through these exercises:

And please do not hesitate to reach out to me directly via email at jondinu@gmail.com or over twitter @clearspandex

Throughout this workshop, you will learn how to make an interactive map of AirBnB listings in SF to better understand the companies impact on the city.