Skip to content

Instantly share code, notes, and snippets.

View mayankdiatm's full-sized avatar
💭
Happy Coding!!

mayankdiatm

💭
Happy Coding!!
View GitHub Profile
@mayankdiatm
mayankdiatm / Python Useful Snippets
Created March 28, 2020 08:58
Python Useful Snippets
collections.Counter()
A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary values.
>>> from collections import Counter
>>>
>>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3]
>>> print Counter(myList)
Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1})
>>>
enumerate()
adds a counter to an iterable and returns it in a form of enumerate object. This enumerate object can then be used directly in for loops
@mayankdiatm
mayankdiatm / multipleOpen.py
Created February 13, 2019 17:09
open multiple files in with statement
from contextlib import contextmanager
@contextmanager
def files(*ff):
fi = [ open(*f) if len(f) == 2 else open(f) for f in ff ]
yield(fi)
map(close,fi)
@mayankdiatm
mayankdiatm / git tutorials.md
Created August 20, 2018 09:57 — forked from jaseemabid/git tutorials.md
Awesome git tutorials I am finding here and there
import cookielib
import urllib2
import json
import base64
import simplejson
import ast
import datetime
import xlsxwriter
import subprocess
import os
####### Search and Match Files in a directory #######
os.chdir(path)
""" take list of all files present
in the directory as a list"""
fnames = [
fname for fname in os.listdir(path)
if os.path.isfile(os.path.join(path, fname))
]
print(fnames)
@mayankdiatm
mayankdiatm / Math.txt
Created February 23, 2018 06:00
Math for Data Science
These courses can help lay the foundation for quantitative thinking.
1. Introduction to Mathematical Thinking
School: Stanford
Platform: Coursera
Instructor: Keith Devlin
Description excerpt: [A] key feature of mathematical thinking is thinking outside-the-box
- a valuable ability in today's world. This course helps to develop that crucial way of thinking.
2.Math is Everywhere: Applications of Finite Math
@mayankdiatm
mayankdiatm / Math.txt
Created February 23, 2018 06:00
Math for Data Science
These courses can help lay the foundation for quantitative thinking.
1. Introduction to Mathematical Thinking
School: Stanford
Platform: Coursera
Instructor: Keith Devlin
Description excerpt: [A] key feature of mathematical thinking is thinking outside-the-box
- a valuable ability in today's world. This course helps to develop that crucial way of thinking.
2.Math is Everywhere: Applications of Finite Math