Skip to content

Instantly share code, notes, and snippets.

View saeedesmaili's full-sized avatar

Saeed Esmaili saeedesmaili

View GitHub Profile
import pandas as pd
df = pd.read_csv('rides.csv')
# Hourly
df_tehran = df.copy()[df.city == "Tehran"]
df_tehran['timestamp'] = pd.to_datetime(df_tehran['timestamp'])
df_tehran_g = df_tehran.groupby([df_tehran.timestamp.dt.hour, df_tehran.service], as_index=True).agg({
'price_per_km': 'mean'
})
@saeedesmaili
saeedesmaili / 1-config.py
Last active June 12, 2020 01:14
Automate tasks with python - 1. Updating Google Sheet
server = 'your_sql_server_address'
database = 'database_name'
username = 'your_username'
password = 'your_password'
@saeedesmaili
saeedesmaili / movielens-1.py
Last active February 10, 2018 19:18
Basic analysis of MovieLens dataset
import pandas as pd
users_columns = ['user_id', 'gender', 'age', 't', 'zip']
df_users = pd.read_table('users.dat', sep='::', header=None, names=users_columns, engine='python')
ratings_columns = ['user_id', 'movie_id', 'rating', 'timestamp']
df_ratings = pd.read_table('ratings.dat', sep='::', header=None, names=ratings_columns, engine='python')
movies_columns = ['movie_id', 'title', 'genres']
df_movies = pd.read_table('movies.dat', sep='::', header=None, names=movies_columns, engine='python')