Grid-Search

Sun 29 June 2025
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: C:\\Users\\Afia Jahan\\anaconda3\\envs\\py312; pyv: 3.12.11 | packaged by Anaconda, Inc. | (main, Jun  5 2025, 12:58:53) [MSC v.1929 64 bit (AMD64)]'
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split …

Category: basics

Read More

Height-Vs-Weight

Sun 29 June 2025
!python --version
Python 3.12.11
!pip install seaborn
Requirement already satisfied: seaborn in c:\users\afia jahan\anaconda3\envs\py312\lib\site-packages (0.13.2)
Requirement already satisfied: numpy!=1.24.0,>=1.20 in c:\users\afia jahan\anaconda3\envs\py312\lib\site-packages (from seaborn) (2 …

Category: basics

Read More

Initialize With Datatype

Sun 29 June 2025
import numpy as np
import pandas as pd
df = pd.DataFrame({'a': [7, 1, 5], 'b': ['3','2','1']}, dtype='object')
df
a b
0 7 3
1 1 2
2 5 …

Category: basics

Read More

Item-In-List

Sun 29 June 2025
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: C:\\Users\\Afia Jahan\\anaconda3\\envs\\py312; pyv: 3.12.11 | packaged by Anaconda, Inc. | (main, Jun  5 2025, 12:58:53) [MSC v.1929 64 bit (AMD64)]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
model_cache = {
    "test1.joblib" : {"one" : "two"}
}
cache_keys = list(model_cache …

Category: basics

Read More

Json-To-Xml

Sun 29 June 2025
import xmltodict
content = {
  "note" : {
    "to" : "Tove",
    "from" : "Jani",
    "heading" : "Reminder",
    "body" : "Don't forget me this weekend!"
  }
}
content
{'note': {'to': 'Tove',
  'from': 'Jani',
  'heading': 'Reminder',
  'body': "Don't forget me this weekend!"}}
xml = xmltodict.unparse(content, pretty=True)
xml
'<?xml version="1.0" encoding="utf-8"?>\n<note>\n\t<to …

Category: basics

Read More

Letter-Match

Sun 29 June 2025
import re
contents = [
    "AB23",
    "A2B3", 
    "DE09",
    "MN90",
    "XYi9",
    "XY90"
]
for content in contents:
    regex_pattern = "(?:AB|DE|XY)\d+" 
    # starts with AB or DE; should contain one or more number

    m = re.match(regex_pattern, content)

    if(m):
        print('matched : '+content)
matched : AB23
matched : DE09
matched : XY90


<>:2: SyntaxWarning: invalid escape sequence …

Category: basics

Read More

List-2

Sun 29 June 2025
entries = ['one', 2, 'three', False]
print(entries)
['one', 2, 'three', False]
print(entries[2:7])
['three', False]
entryTuple = (100, 200, 'three', 'four')
print(entryTuple)
(100, 200, 'three', 'four')
cities = ['Toronto', 'Monteal', 'Vancouver']
print(cities)
['Toronto', 'Monteal', 'Vancouver']
users = [
    ('Anders', 'A', 21),
    ('Balmer', 'B', 45),
    ('Stephe', 'S', 24)
]

print(users)
[('Anders …

Category: basics

Read More

List-Diff-Dt

Sun 29 June 2025
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: C:\\Users\\Afia Jahan\\anaconda3\\envs\\py312; pyv: 3.12.11 | packaged by Anaconda, Inc. | (main, Jun  5 2025, 12:58:53) [MSC v.1929 64 bit (AMD64)]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
lista = ["one", 2, "three", 4]
type(lista)
list …

Category: basics

Read More

List-Ref

Sun 29 June 2025
a = [
    1, 2, 3, 4
]
b = a
b
[1, 2, 3, 4]
b.append(5)
a
[1, 2, 3, 4, 5]
c = a.copy()
c.append(6)
a
[1, 2, 3, 4, 5]


Score: 5

Category: basics

Read More

List-Remove

Sun 29 June 2025
names = [
    "Kevin",
    "Peter",
    "John"
]
names
['Kevin', 'Peter', 'John']
names.pop(0)
'Kevin'
names
['Peter', 'John']


Score: 5

Category: basics

Read More
Page 3 of 7

« Prev Next »