Skip to content

Instantly share code, notes, and snippets.

View pulkitpahwa's full-sized avatar
🎯
Focusing

Pulkit Pahwa pulkitpahwa

🎯
Focusing
View GitHub Profile
@pulkitpahwa
pulkitpahwa / gist:8bceb026053eac1c91ef3b513813d975
Last active November 11, 2017 05:24
Tensorflow Workshop setup
## Installation Steps
For Mac and Linux users
1. Go to Anaconda page (link: https://www.anaconda.com/download). Download and install the Python 3.6 version. For more info, you can visit this webpage (Mac users: https://docs.anaconda.com/anaconda/install/mac-os, Linux users: https://docs.anaconda.com/anaconda/install/linux)
2. Create a FloydHub account (link: https://www.floydhub.com/signup). Make sure you create a FloydHub account with the same email address with which you have registered for DataHack Summit 2017. Only then we will be able to assign GPU credits.
3. Install FloydHub in your system by going to the terminal by executing
@pulkitpahwa
pulkitpahwa / models.py
Last active October 4, 2020 06:44
An example on how to use F expressions
import uuid
from django.db import models
# assuming we have our User model implemented in the users app
from users.models import User
class Contest(models.Model):
# I prefer using UUID field instead of auto increment for storing id
id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)
@pulkitpahwa
pulkitpahwa / tata_motors_sales.py
Created October 5, 2020 06:19
Tata Motors sales data for May and June 2020
may_2020 = {"tata altroz": 1379, "tata tiago": 857, "tata nexon": 623, "tata harrier": 161, "tata tigor": 132}
june_2020 = {"tata tiago": 4069, "tata altroz": 3104, "tata nexon": 3040, "tata harrier": 3040, "tata tigor": 553}
@pulkitpahwa
pulkitpahwa / dict_sum_naive_idea.py
Created October 5, 2020 06:25
Naive process of summing 2 dictionaries
# continued from https://gist.github.com/pulkitpahwa/a42aaafa4d6290a453299cec6bce64fc
sum_may_june_2020 = {}
for car, units_sold in may_2020.items():
sum_may_june_2020[car] = sum_may_june_2020.get(car, 0) + units_sold
for car, units_sold in june_2020.items():
sum_may_june_2020[car] = sum_may_june_2020.get(car, 0) + units_sold
# continued from https://gist.github.com/pulkitpahwa/a42aaafa4d6290a453299cec6bce64fc
from collections import Counter
may_2020 = Counter(may_2020)
june_2020 = Counter(june_2020)
sum_may_june_2020 = may_2020 + june_2020
@pulkitpahwa
pulkitpahwa / python_collections_example2.py
Created October 5, 2020 08:23
More examples of python collections
# continued from https://gist.github.com/pulkitpahwa/d70d6855b5fba23f5b439b1cae556ad1
a = Counter({"tata": ["tiago", "nano"]})
b = Counter({"tata": ["nexon"]})
c = a + b
print(c)