Python Code Samples



Filters


How to get number of queries executed in Django orm
kishore_kumar | 6 years, 1 month
from django.db import connection

tasks = Task.objects.all()
python django django-orm
Generate Pie Chart in python using matplotlib
kishore_kumar | 6 years, 11 months
import matplotlib.pyplot as plt

labels = 'Grapes', 'Oranges', 'Mangoes', 'Apples'
python matplotlib
Create a line chart using python matplotlib
kishore_kumar | 6 years, 11 months
import matplotlib.pyplot as plt

t = ['12-03-18','12-04-18' , '12-05-18', '12-06-18', '12-07-18']
python matplotlib
How to get Django avatar in views or models
kishore_kumar | 6 years, 9 months
django.contrib.auth.models import User
from avatar.templatetags.avatar_tags import avatar_url

python django-avatar
How to combine two query sets in Django ORM
kishore_kumar | 6 years, 1 month
q1 = Task.objects.filter(id__lt=4)
q2 = Task.objects.filter(completed=True)

python django django-orm
Ramya
Indexed DataFrames using Arrays
Ramya | 6 years, 3 months
import pandas as pd
data = {'Subject':['Maths', 'Science', 'English'],'Marks':[70,80,90]}
df = pd.
python pandas dataframe
round a floating point number in python
kishore_kumar | 6 years, 11 months
my_number = 123.83725

print round(my_number, 2) # 123.84
python
Python pickle dump
Reshma | 5 years, 11 months
import pickle

number_of_data = int(input('Enter the number of data : '))
python pickle dump
how to log full traceback using python logging
kishore_kumar | 6 years, 1 month
import logging
  
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=
python logging
unzip file from gz files using python
kishore_kumar | 6 years
import gzip
import shutil
with gzip.open('my_file.gz', 'rb') as f_in:
python gzip
Prev Next