Ttl-Cache-1

Fri 14 November 2025

title: "TTL Cache Check" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from cachetools import TTLCache 
import time
cache = TTLCache(maxsize=10, ttl=10)
cache['city'] = 'Toronto'
print(cache['city'])
Toronto
time.sleep(5)
if('city' in cache):
    print(cache['city'])
else:
    print('Cache not found')
Toronto
time.sleep …

Category: basics

Read More

Twitter-Analysis

Fri 14 November 2025

title: "Twitter Analysis" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import nltk
from nltk.probability import FreqDist, DictionaryProbDist, ELEProbDist
pos_tweets = [('I love this car', 'positive'),
              ('This view is amazing', 'positive'),
              ('I feel great this morning', 'positive'),
              ('I am so excited about the concert', 'positive'),
              ('He is …

Category: sentiment

Read More

Two

Fri 14 November 2025
!python --version
Python 3.10.5
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Load the dataset
tips = sns.load_dataset("tips")
# Create a PairGrid with regression and histogram plots
g = sns.PairGrid(tips, diag_sharey=False, hue="sex", palette="Set2")
g.map_upper(sns.scatterplot, alpha=0 …

Category: seaborn

Read More

Two-Bars-2343

Fri 14 November 2025

import numpy as np
import matplotlib.pyplot as plt

N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans …

Category: barchart

Read More

Two-Bars-Mob

Fri 14 November 2025


import numpy as np
import matplotlib.pyplot as plt


menMeans = (154, 138, 161, 181, 151, 162, 156, 188, 145, 153, 124, 144);
N = len(menMeans);


print(type(menMeans));

ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars

fig, ax = plt.subplots …

Category: barchart

Read More

Unicode-Dammit

Fri 14 November 2025

title: "Unicode Dammit" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from bs4 import UnicodeDammit
print("inside main method")

dammit = UnicodeDammit(b"Sacr\xc3\xa9 bleu!")
inside main method
print(type(dammit))
<class 'bs4.dammit.UnicodeDammit'>
print(dammit.unicode_markup)
Sacré bleu!
print(type(dammit.unicode_markup))
<class 'str'>
print(dammit …

Category: basics

Read More

Unicode-Issue-And-Fix

Fri 14 November 2025

title: "Unicode Issue and Fix" author: "Rj" date: 2019-04-22 description: "-" type: technical_note draft: false


import numpy as np
import pandas as pd
df = pd.read_csv('score.csv')
---------------------------------------------------------------------------

UnicodeDecodeError                        Traceback (most recent call last)

<ipython-input-2-aee192733216> in <module>()
----> 1 df = pd.read_csv('score.csv')


~/anaconda3/envs/py36/lib/python3 …

Category: data-wrangling

Read More

Untitled

Fri 14 November 2025
!pip install smtplib
ERROR: Could not find a version that satisfies the requirement smtplib (from versions: none)
ERROR: No matching distribution found for smtplib

fromaddr = 'fromuser@gmail.com'
toaddrs  = 'touser@gmail.com'

# Writing the message (this …

Category: game20241121

Read More

Updating Variable State

Fri 14 November 2025

title: "Updating Variable State" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.Variable(0, name = 'counter')

b = tf.add(a, tf.constant(2))

# update a with …

Category: tensorflow-work

Read More

User-Input

Fri 14 November 2025

title: "User input" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


city = input("Enter your city : ")
Enter your city : Toronto
city
'Toronto'


Score: 0

Category: basics

Read More
Page 140 of 146

« Prev Next »