Python Code Samples



Filters


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

tasks = Task.objects.all()
python django django-orm
convert string to python datetime object
kishore_kumar | 6 years, 9 months
import datetime

st = "2019-08-19 05:40"
python datetime
Draw a basic plot using matplotlib
harika | 7 years, 3 months
import matplotlib.pyplot as plt
import numpy as np
ar = np.arange(0, 5, 0.2)
python matplotlib
Generate Pie Chart in python using matplotlib
kishore_kumar | 7 years, 6 months
import matplotlib.pyplot as plt

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

t = ['12-03-18','12-04-18' , '12-05-18', '12-06-18', '12-07-18']
python matplotlib
Using python generator for finding factors
kishore_kumar | 6 years, 9 months
def get_factors(num):
    i = 1
    while i * i < num:
python generator factors
how to log full traceback using python logging
kishore_kumar | 6 years, 8 months
import logging
  
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=
python logging
Ramya
Indexed DataFrames using Arrays
Ramya | 6 years, 9 months
import pandas as pd
data = {'Subject':['Maths', 'Science', 'English'],'Marks':[70,80,90]}
df = pd.
python pandas dataframe
How to get Django avatar in views or models
kishore_kumar | 7 years, 3 months
django.contrib.auth.models import User
from avatar.templatetags.avatar_tags import avatar_url

python django-avatar
Ramya
Indexed DataFrame using list of dictionaries
Ramya | 6 years, 9 months
import pandas as pd
data = [{'Python': 90, 'C': 84,'java':65},{'Python': 78, 'C': 90, 'java': 65}]
python pandas dataframe
Prev Next