Python Code Samples



Filters


convert string to python datetime object
kishore_kumar | 5 years, 2 months
import datetime

st = "2019-08-19 05:40"
python datetime
durga
Writing into files in python
durga | 5 years, 3 months
file = open('open.txt','w') 
 
file.write('Hi there!') 
python file handling
Remove directory / folder in python
harika | 5 years, 8 months
'''
You can remove empty directory by rmdir function.
But to remove non empty directory we have to
Shuttle : A module that offers a number of high-level operations on files and collections of files.
shutil python os
Ramya
Indexed DataFrame using list of dictionaries
Ramya | 5 years, 3 months
import pandas as pd
data = [{'Python': 90, 'C': 84,'java':65},{'Python': 78, 'C': 90, 'java': 65}]
python pandas dataframe
How to get first day of the month in python
kishore_kumar | 2 years, 10 months
from datetime import datetime

first_day = datetime.today().date().replace(day=1)
python datetime
get all keys from redis with python
kishore_kumar | 4 years, 10 months
import redis # pip install redis
r = redis.Redis(host='localhost', port='6379')

python redis
convert python date time object to specific format using strftime
kishore_kumar | 5 years, 2 months
import datetime

st = "2019-08-19 05:40"
python datetime
How to load a pickle file in python
harika | 5 years, 1 month
with open('train.pickle', 'rb') as f:
    X_train, y_train = pickle.load(f)
python pickle file
Python pickle dump
Reshma | 4 years, 10 months
import pickle

number_of_data = int(input('Enter the number of data : '))
python pickle dump
send mail using sendgrid python
kishore_kumar | 5 years, 3 months
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
python sendgrid
Prev Next