Skip to content

Instantly share code, notes, and snippets.

View carleen's full-sized avatar

Carleen carleen

  • Baltimore, MD
View GitHub Profile
@carleen
carleen / airbnb_dummy_variable.py
Last active May 5, 2023 23:18
Some functions for working with variables on the Airbnb Dataset
# Change some of the variables in room type, prevents errors
df.room_type = df.room_type.map({'Private room': 'private_room',
'Entire home/apt': 'entire_property',
'Shared room': 'shared_room'})
# Adjusts variables for host response times
df.host_response_time = df.host_response_time.map({'within an hour': 'lt_hour',
'within a few hours': 'lt_few_hours',
'within a day': 'lt_day',
'a few days or more': 'gt_day'})
@carleen
carleen / response_time_query.py
Created April 30, 2023 20:49
Query host response time from AirBnB data, and fill any '' and 'N/A' values with the most frequent values
import sqlite3
# Connect to the SQLite database
conn = sqlite3.connect(db_path)
# Create a cursor object
cur = conn.cursor()
# Execute the query
query = '''SELECT host_response_time, COUNT(*) AS cnt
-- Table: order
DROP TABLE IF EXISTS orders;
CREATE TABLE orders(
id int PRIMARY KEY,
paymentID int NOT NULL,
chargeID int NOT NULL
);
-- Table: item
DROP TABLE IF EXISTS item;
@carleen
carleen / reids.py
Last active February 20, 2023 16:28
from tabulate import tabulate
import sqlite3
import json
from datetime import datetime
con = sqlite3.connect('reids.db')
reid_json = json.load(open('reids.json'))
cur=con.cursor()
order_id = 1
@carleen
carleen / plague.py
Last active February 3, 2021 23:12
'''
We'll need three variables to solve this Eigenvalue Problem (based on a Lesile model):
A = the "Leslie matrix"
p_i = the initial population breakdown of healthy, sick, and deceased individuals
percentage = stop value (percentage of healthy + sick people)
'''
import numpy as np
# Our initial Leslie matrix for the system