Compress Image

Fri 14 November 2025

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


from PIL import Image
# Open the image
im = Image.open("/Users/rajacsp/datasets/barcode_images/orange.jpg")

im.save("/Users/rajacsp/datasets/barcode_images/orange_3.jpg", format="JPEG", quality=70)


Score: 0

Category: basics

Read More

Compress Image Cv2

Fri 14 November 2025

title: "Compress Image CV2" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


from PIL import Image
import cv2
# Open the image
img = cv2.imread('/Users/rajacsp/datasets/barcode_images/orange.jpg')


# save image with lower compression—bigger file size but faster decoding
#cv2.imwrite('/Users/str-kwml0011/datasets/random_images …

Category: basics

Read More

Constants

Fri 14 November 2025

title: "Constants" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


from scipy.constants import pi
pi
3.141592653589793
from scipy.constants import golden
golden
1.618033988749895
from scipy.constants import G
G
6.67408e-11
from scipy.constants import speed_of_light as sol
sol
299792458.0


Score: 10

Category: scipy

Read More

Consume-Rest-Api

Fri 14 November 2025

import requests
import json
response = requests.get("https://randomuser.me/api/")
response_json = response.json()
print(response_json)
{'results': [{'gender': 'female', 'name': {'title': 'Ms', 'first': 'Mia', 'last': 'Walker'}, 'location': {'street': {'number': 8562, 'name': 'Port Hills Road'}, 'city': 'Hamilton', 'state': 'Waikato', 'country': 'New Zealand', 'postcode': 45938, 'coordinates': {'latitude': '54.8821', 'longitude': '15.6902 …

Category: basics

Read More

Content-Summary

Fri 14 November 2025

title: "Content Summary" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


from gensim.summarization import summarize, keywords
from pprint import pprint
from smart_open import smart_open
text = " ".join((line for line in smart_open('sample.txt', encoding='utf-8')))
text
'More than half of survey participants also reported clicking on …

Category: gensim-samples

Read More

Copy List

Fri 14 November 2025

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


import copy
a = [1, 2, 3]
b = copy.copy(a)
b
[1, 2, 3]
b.append(4)
a
[1, 2, 3]
b
[1, 2, 3, 4]
# deep copy

c = copy.deepcopy(a)
c
[1, 2, 3 …

Category: basics

Read More

Coroutine-Sample

Fri 14 November 2025
import asyncio 
import time

async def test():
    print('inside test')

async def foo():
    await test()  # No exception raised.
    print('foo')
foo()
<coroutine object foo at 0x7f54f8e83940>


Score: 0

Category: async

Read More

Correlation-1

Fri 14 November 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml312-2024; pyv: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:27:36) [GCC 11.2.0]'
print(pyu.ps2("pandas"))
pandas==2.2.3

import pandas as pd
import numpy as np
def histogram_intersection(a, b):
    v …

Category: pandas

Read More

Count-Plot

Fri 14 November 2025

title: "Count Plot (Buggy)" author: "Rj" date: 2020-09-05 description: "List Test" type: technical_note draft: false


# https://www.machinelearningplus.com/plots/top-50-matplotlib-visualizations-the-master-plots-python/
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import seaborn as sns
import warnings; warnings.filterwarnings(action='once')

# Import Data
df = pd.read_csv("https …

Category: plot

Read More

Counter-On-News

Fri 14 November 2025

title: "Counter On News" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import re
from collections import Counter
words = re.findall(r'\w+', open('../../../assets/news.txt').read().lower())
Counter(words).most_common(10)
[('a', 37),
 ('and', 36),
 ('to', 30),
 ('the', 27),
 ('that', 24),
 ('of', 18),
 ('employees', 17 …

Category: basics

Read More
Page 94 of 146

« Prev Next »