Skip to content

Instantly share code, notes, and snippets.

View igorkf's full-sized avatar

Igor Kuivjogi Fernandes igorkf

View GitHub Profile
@igorkf
igorkf / reduce_df_memory.py
Last active October 7, 2022 01:27
Reduce memory usage of Pandas DataFrame
import pandas as pd
import numpy as np
from tqdm import tqdm
def reduce_mem_usage(df):
"""
From https://www.kaggle.com/valleyzw/ubiquant-lgbm-baseline
Iterate through all the columns of a dataframe and modify the data type to reduce memory usage.
"""
group_user_relation = db.Table(
'group_user_relation',
db.Column('group_id', db.Integer, db.ForeignKey('group.id')),
db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), unique=True)