id
stringlengths
8
8
code
stringclasses
17 values
explanation
stringclasses
17 values
context
stringclasses
17 values
language
stringclasses
1 value
difficulty
stringclasses
3 values
tags
listlengths
2
2
version
stringclasses
1 value
keywords
listlengths
3
3
1551f7d5
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Thường dùng trong data preprocessing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
61f99228
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Thường dùng trong data preprocessing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
3190470a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Kiểm tra số nguyên tố. Dùng all() để check tất cả divisors.
Thường dùng trong data preprocessing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
c5c324bd
# File I/O def read_file(path): with open(path) as f: return f.read()
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
9b33eb95
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f184b389
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4a2654d0
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
0dd9389a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
3718946a
def count_chars(text): return {c: text.count(c) for c in set(text)}
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
7e5dc0b3
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3b2f43af
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
207e297e
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
ac5e02fc
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
e14bdd51
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
b0579396
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
44343db5
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
0fd83e6c
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
2f6fbd76
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
dcb2d0c4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
4ac36b35
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Base class cơ bản. **kwargs để flexible initialization.
Thường dùng trong data preprocessing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
4773e42d
# File I/O def read_file(path): with open(path) as f: return f.read()
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
ccf5f753
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
5af612b3
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
79db3cd8
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7c5eee11
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
31425586
def count_chars(text): return {c: text.count(c) for c in set(text)}
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
09edc9b3
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
fe8da20f
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
81e9a109
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
c45813de
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
63283a29
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
71ca4fc1
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
4e02be50
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
280a654b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
73b7c592
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
a5d704cc
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
bbdf7398
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Decorator log_calls ghi lại mỗi lần function được gọi.
Thường dùng trong data preprocessing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
18f49517
# File I/O def read_file(path): with open(path) as f: return f.read()
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f385c22f
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
2ba35ebb
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ce273b41
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
39887cf1
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4b6bb33b
def count_chars(text): return {c: text.count(c) for c in set(text)}
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
2d4e6269
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
872d0147
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1ff29406
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
6ad7263b
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
10ffacb4
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4c818821
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e4f83bf7
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
9854d6fe
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
4727f364
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
5e2dcdd7
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8b9d627f
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Fetch data từ API endpoint. Trả về JSON.
Thường dùng trong data preprocessing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
6ca762d1
# File I/O def read_file(path): with open(path) as f: return f.read()
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
fd7dc475
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
f3527dd2
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
90027ed1
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
90ccac2f
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
03a618e8
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
80dc794e
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
459eaf29
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8f6dcf76
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
f957de36
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
c08516f7
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
04751876
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
217a521e
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ba77589b
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
aa99f1a9
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
84d77a26
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
8bf115a7
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Thường dùng trong data preprocessing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
b39e8791
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
32470a00
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
0b203e98
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
ae269bba
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
daee990d
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
8016deae
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
47fde0e6
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ce9a28e4
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9c464c34
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
338481cc
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
1f7f92da
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6cf03338
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
1d0b773c
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
4888b951
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
6fbdb0c4
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6ca31ab4
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
2293c698
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Thường dùng trong data preprocessing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
c9beaa8c
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
fe276db6
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
b46bb008
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4c1019a4
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
6037c0c9
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
8abcf53a
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
f388161f
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
d7f04fb2
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9f62990f
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
79a57dba
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
d333c63a
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
4103eee7
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Thường dùng trong data preprocessing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]