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
# 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
$(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
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
''' | |
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
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Jun 8 17:19:13 2019 | |
@author: 63315 | |
""" | |
import googlemaps | |
from datetime import datetime |
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
# check attachment files | |
# find_distance.py | |
import os | |
from datetime import datetime | |
import googlemaps | |
from django.conf import settings | |
from packages.common_func import get_or_none, convert_float | |
from network.models import Distance, LatLong |
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
pip install boto3 | |
python manage.py runserver | |
pip install awscli | |
aws --version | |
aws configure # set configuration of user | |
aws s3 ls # get listing of all buckets | |
aws s3 ls s3://imageprocess-python/ # access certain bucket |
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
''' | |
Ref blog | |
- https://www.programiz.com/python-programming/user-defined-exception | |
- https://stackoverflow.com/questions/1319615/proper-way-to-declare-custom-exceptions-in-modern-python | |
''' | |
# Basic use | |
class CustomError(Exception): | |
pass |