Counter-Simple

Fri 14 November 2025

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


from collections import Counter
a = Counter("Hello there, How are you")
a
Counter({' ': 4,
         ',': 1,
         'H': 2,
         'a': 1,
         'e': 4,
         'h': 1,
         'l': 2,
         'o': 3,
         'r': 2,
         't': 1,
         'u': 1,
         'w': 1,
         'y …

Category: basics

Read More

Create-Temp-File

Fri 14 November 2025
import tempfile
fp = tempfile.TemporaryFile()
fp.name
55
fp.write(b'Hey Toronto')
11
fp.seek(0)
0
fp.read()
b'Hey Toronto'
# Close the file

fp.close()


Score: 5

Category: file-utils

Read More

Cricket Match 2 Over

Fri 14 November 2025

title: "Cricket Match 2 Overs" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import time
import random as rd
team_1_score = 0
team_2_score = 0
def play_over(over, t_score):

    print('Over ', over)

    for x in range(6):

        score = rd.randint(0, 6)
        t_score += score
        print('Ball ', (x+1), score …

Category: basics

Read More

Csv-Monitor

Fri 14 November 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==0.21.0

import pandas as pd …

Category: pandas

Read More

Csv-To-Dataframe

Fri 14 November 2025

title: "CSV to Dataframe" author: "Rj" date: 2019-04-22 description: "-" type: technical_note draft: false


import numpy as np
import pandas as pd
csv = pd.DataFrame.from_csv('uk-500.csv')
/Users/rajacsp/anaconda3/envs/py36/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: from_csv is deprecated. Please use read_csv(...) instead. Note that …

Category: data-wrangling

Read More

Csv-To-Dataframe-2693

Fri 14 November 2025
import numpy as np
import pandas as pd
df = pd.read_csv('https://s3-eu-west-1.amazonaws.com/shanebucket/downloads/uk-500.csv')
df
first_name last_name company_name address city county postal phone1 phone2 email web
0 …

Category: pandas

Read More

Csv2Duckdb-Persist

Fri 14 November 2025

import duckdb

# Create a new DuckDB database file
db_path = 'student_duck1.db'
con = duckdb.connect(database=db_path, read_only=False)

# Verify the connection
print(f"Connected to DuckDB database at {db_path}")
Connected to DuckDB database at student_duck1.db
# Path to your CSV file
csv_file_path = '../dataset/student_data.csv'

# Load the CSV file into …

Category: duckdb

Read More

Cumulatiave Distribution Function 1

Fri 14 November 2025

title: "Cumulative Distribution Function" author: "Raja CSP Raman" date: 2019-05-06 description: "-" type: technical_note draft: false


import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('random_timestamp.txt')

print(data)

# Choose how many bins you want here
num_bins = 20

# Use the histogram function to bin the data
counts, bin_edges …

Category: scipy

Read More

Cumulatiave Distribution Function 2

Fri 14 November 2025

title: "Cumulative Distribution Function 2" author: "Raja CSP Raman" date: 2019-05-06 description: "-" type: technical_note draft: false


import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('random_timestamp.txt')

print(data)

sorted_data = np.sort(data)

yvals=np.arange(len(sorted_data))/float(len(sorted_data)-1)

plt.plot(sorted_data,yvals)

plt …

Category: scipy

Read More

Current-Directory

Fri 14 November 2025

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


import os
dirpath = os.getcwd()
print("current directory is : " + dirpath)
current directory is : /Users/rajacsp/projects/mlnotes/content/python/basics
foldername = os.path.basename(dirpath)
print("Directory name is : " + foldername)
Directory name is : basics
scriptpath = os …

Category: basics

Read More
Page 95 of 146

« Prev Next »