This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from datetime import datetime | |
from django.conf import settings | |
from django.db import connection | |
from django.core.files.storage import FileSystemStorage | |
def get_dict_wise_data(columns,cursor): | |
results = [] | |
for row in cursor.fetchall(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
For more information visit official documents | |
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-examples.html | |
''' | |
import boto3 | |
from botocore.errorfactory import ClientError | |
from boto3.s3.transfer import S3Transfer | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LIST VIEW: | |
from django.views.generic import ListView | |
** Simple example | |
class UsersListView(ListView): | |
model = User | |
** You can add attributes to change the default behaviour. | |
class UsersListView(ListView): | |
model = User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('keypress', '.only-numbers', function(e){ | |
var keycode = (e.which) ? e.which : e.keyCode; | |
if (!(keycode==8 || keycode == 46)&&(keycode < 48 || keycode > 57)){ | |
return false; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://towardsdatascience.com/10-python-pandas-tricks-that-make-your-work-more-efficient-2e8e483808ba | |
pd.read_csv('file_name.csv', nrows = 5, usecols=['c1', 'c2'], dtype = {‘c1’: str, ‘c2’: int, …}) | |
argument | |
* nrows = 5 (it will select only 5 rows from dataframe) | |
* usecols (select certain columns on df creation) | |
* dtype (specify col data type) | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source Blog: https://medium.com/jbennetcodes/how-to-rewrite-your-sql-queries-in-pandas-and-more-149d341fc53e?source=search_post---------0 | |
-> Sql queries vs pandas queries | |
* select Query | |
-> select * from airports; | |
-> airports.head() | |
* select query with limit | |
-> select * from airports limit 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Tuesday 23-July-2019 | |
@author: Vikas shrivastava | |
For more info go to official documentation of folium https://python-visualization.github.io/folium/modules.html | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python script for batch geocoding of addresses using the Google Geocoding API. | |
This script allows for massive lists of addresses to be geocoded for free by pausing when the | |
geocoder hits the free rate limit set by Google (2500 per day). If you have an API key for paid | |
geocoding from Google, set it in the API key section. | |
Addresses for geocoding can be specified in a list of strings "addresses". In this script, addresses | |
come from a csv file with a column "Address". Adjust the code to your own requirements as needed. | |
After every 500 successul geocode operations, a temporary file with results is recorded in case of | |
script failure / loss of connection later. | |
Addresses and data are held in memory, so this script may need to be adjusted to process files line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Dump and Restore : | |
mongodump --db=<old_db_name> --collection=<collection_name> --out=data/ | |
mongorestore --db=<new_db_name> --collection=<collection_name> data/<db_name>/<collection_name>.bson | |
Loop on mongodb query: | |
db.users.find().forEach( function(myDoc) { print( "user: " + myDoc.name ); } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import pandas as pd | |
import pymongo | |
def import_content(filepath): | |
mng_client = pymongo.MongoClient('localhost', 27017) | |
mng_db = mng_client['route_planning'] | |
collection_name = 'lat_long' |