Python Code Samples



Filters


Generate Pie Chart in python using matplotlib
kishore_kumar | 6 years, 9 months
import matplotlib.pyplot as plt

labels = 'Grapes', 'Oranges', 'Mangoes', 'Apples'
python matplotlib
Draw a basic plot using matplotlib
harika | 6 years, 7 months
import matplotlib.pyplot as plt
import numpy as np
ar = np.arange(0, 5, 0.2)
python matplotlib
Python logging basic example to print from debug
kishore_kumar | 6 years
import logging
logging.basicConfig(level=logging.DEBUG)

python logging
How to get Django avatar in views or models
kishore_kumar | 6 years, 7 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 | 5 years, 12 months
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, 1 month
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, 9 months
my_number = 123.83725

print round(my_number, 2) # 123.84
python
unzip file from gz files using python
kishore_kumar | 5 years, 11 months
import gzip
import shutil
with gzip.open('my_file.gz', 'rb') as f_in:
python gzip
Ramya
Indexed DataFrame using list of dictionaries
Ramya | 6 years, 1 month
import pandas as pd
data = [{'Python': 90, 'C': 84,'java':65},{'Python': 78, 'C': 90, 'java': 65}]
python pandas dataframe
Text identification in the image using google vision API with python
kishore_kumar | 6 years, 5 months
from google.cloud import vision
from google.cloud.vision import types

python google vision
Prev Next