Python Code Samples



Filters


How to get Django avatar in views or models
kishore_kumar | 6 years, 4 months
django.contrib.auth.models import User
from avatar.templatetags.avatar_tags import avatar_url

python django-avatar
Draw a basic plot using matplotlib
harika | 6 years, 4 months
import matplotlib.pyplot as plt
import numpy as np
ar = np.arange(0, 5, 0.2)
python matplotlib
How to combine two query sets in Django ORM
kishore_kumar | 5 years, 9 months
q1 = Task.objects.filter(id__lt=4)
q2 = Task.objects.filter(completed=True)

python django django-orm
Ramya
Indexed DataFrames using Arrays
Ramya | 5 years, 11 months
import pandas as pd
data = {'Subject':['Maths', 'Science', 'English'],'Marks':[70,80,90]}
df = pd.
python pandas dataframe
convert string to python datetime object
kishore_kumar | 5 years, 10 months
import datetime

st = "2019-08-19 05:40"
python datetime
unzip file from gz files using python
kishore_kumar | 5 years, 8 months
import gzip
import shutil
with gzip.open('my_file.gz', 'rb') as f_in:
python gzip
Python logging basic example to print from debug
kishore_kumar | 5 years, 9 months
import logging
logging.basicConfig(level=logging.DEBUG)

python logging
round a floating point number in python
kishore_kumar | 6 years, 6 months
my_number = 123.83725

print round(my_number, 2) # 123.84
python
Text identification in the image using google vision API with python
kishore_kumar | 6 years, 2 months
from google.cloud import vision
from google.cloud.vision import types

python google vision
Ramya
Indexed DataFrame using list of dictionaries
Ramya | 5 years, 11 months
import pandas as pd
data = [{'Python': 90, 'C': 84,'java':65},{'Python': 78, 'C': 90, 'java': 65}]
python pandas dataframe
Prev Next