Skip to content

Instantly share code, notes, and snippets.

View vikas-git's full-sized avatar

Vikas Shrivastava vikas-git

  • Gurgaon
View GitHub Profile
@vikas-git
vikas-git / dataframe_func_query.txt
Last active August 18, 2019 17:53
Important Query for Pandas Dataframe
# search with and/or condition
df4 = df3.query('(From=="AHH" & To=="BBH") | (From=="BBH" & To=="AHH")')
OR
data.loc[(data["Gender"]=="Female") & (data["Education"]=="Not Graduate") & (data["Loan_Status"]=="Y"), ["Gender","Education","Loan_Status"]]
# Rows to columns
df = df.stack().reset_index().rename(columns={'level_0':'From','level_1':'To', 0:'Hours'})
# Join two df like sql join
df1 = df1.merge(record_df, on='location_code', how='outer', suffixes=('_x', '_y'))
@vikas-git
vikas-git / python_interview.txt
Last active September 27, 2023 14:34
My Interview experience on Python
======= Interviews ==========
# Duration July - August 2021
## Django:
* Flow of Django
* Django Middlewares
* Django request/response cycle
* API security(auth based token and others)
* Avoid deadloak in django ( F() )
@vikas-git
vikas-git / git_command.txt
Last active December 8, 2019 13:17
Git basic commands
# Git clone from specific branch
git clone -b my-branch [email protected]:user/myproject.git
# Before pushed code need to run given command..
git stash clear; git stash; git pull; git stash apply;
git commit files
git add .
git commit -m "udpate"
git push
@vikas-git
vikas-git / jquery.validate.addtional.js
Created February 28, 2019 07:19
Jquery Validate :: Additional validation for different type of value check.
$.validator.addMethod("emailFormat",
function (value, element) {
// return !/[0-9]*/.test(value);
return this.optional(element) || /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(value);
},
//'Please enter a valid email address.'
"Please enter a valid email"
);
$.validator.addMethod("blankSpace",
function (value, element) {
@vikas-git
vikas-git / decorator.py
Created February 28, 2019 06:37
Django :: Create user define decorator
from django.http import HttpResponseRedirect
def authors_only(function):
def wrap(request, *args, **kwargs):
profile = request.user.get_profile()
if profile.usertype == 'Author':
return function(request, *args, **kwargs)
else:
return HttpResponseRedirect('/')
@vikas-git
vikas-git / .gitignore
Created February 28, 2019 06:28
Gitignore file common uses for Python
# It ignore whole certain directory
env/
instance/*
# It ignore all files in certain directory but not given directory
!instance/.gitkeep
!migrations/__init__.py
# It ignore all files which has certain extension
*.pyc