Python Code Samples



Filters


Get User Presence of Slack user with slack api and python
kishore_kumar | 6 years, 10 months
from slackclient import SlackClient

user_token = "xoxp-2284524168-327340147858-399021736478-b7ed2
python slack-api
conditional selection with numpy arrays
kishore_kumar | 7 years, 5 months
import numpy as np
ser_arr = np.arange(1,10)
mat1 = ser_arr.reshape(3,3)
numpy python
Draw subplots in matplotlib
harika | 7 years
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
You can see the output in the attached image. If you want to play with plot then set specific prope
python matplotlib
Create a dataframe in pandas with dictionary
harika | 7 years
import pandas as pd
name_dataset = pd.DataFrame({
    "city": ["Bangalore", "Hyderabad", "Chennai"
python pandas
get date ctime from python datetime
kishore_kumar | 6 years, 7 months
import datetime

today = datetime.date.today()
python datetime
Create a dataframe in pandas with lists
harika | 7 years
import pandas as pd
data = [['Alex',10],['Bob',12],['Clarke',13]]
df = pd.DataFrame(data,columns=[
python pandas list
Python logging basic example to print from debug
kishore_kumar | 6 years, 5 months
import logging
logging.basicConfig(level=logging.DEBUG)

python logging
convert string to python datetime object
kishore_kumar | 6 years, 6 months
import datetime

st = "2019-08-19 05:40"
python datetime
How to get number of queries executed in Django orm
kishore_kumar | 6 years, 5 months
from django.db import connection

tasks = Task.objects.all()
python django django-orm
Draw a basic plot using matplotlib
harika | 7 years
import matplotlib.pyplot as plt
import numpy as np
ar = np.arange(0, 5, 0.2)
python matplotlib
Prev Next