Fill-Random-Marks
import numpy as np
import pandas as pd
datatype = [('Science', 'int32'), ('Maths', 'int32')]
current_values = np.zeros(3, dtype=datatype)
current_index = ['Row '+str(i) for i in range(1, 4)]
df = pd.DataFrame(current_values, index=current_index)
Read More
Item-In-List
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 …
Read More
Json-To-Xml
content = {
"note" : {
"to" : "Tove",
"from" : "Jani",
"heading" : "Reminder",
"body" : "Don't forget me this weekend!"
}
}
{'note': {'to': 'Tove',
'from': 'Jani',
'heading': 'Reminder',
'body': "Don't forget me this weekend!"}}
xml = xmltodict.unparse(content, pretty=True)
'<?xml version="1.0" encoding="utf-8"?>\n<note>\n\t<to …
Read More
Letter-Match
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 …
Read More
List-2
entries = ['one', 2, 'three', False]
['one', 2, '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)
Read More
List-Diff-Dt
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]
Read More