syropiatovvv 2 месяцев назад
Родитель 77ec8ba8d8
Сommit 9a8e76b439

2
.gitignore поставляемый

@ -2,3 +2,5 @@
# virtual environments
.venv/
.venv*/
# data
data/

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

@ -0,0 +1,19 @@
from collections.abc import Iterable, Iterator
class _ZipSentinel:
pass
_ZIP_SENTINEL: _ZipSentinel = _ZipSentinel()
def zip_n(*iterables: Iterable, n: int) -> Iterator[tuple]:
n = max(n, 0)
if len(iterables) == 0:
for i in range(n):
yield ()
return
iterators = list(map(iter, iterables))
for i in range(n):
tup = tuple(next(it, _ZIP_SENTINEL) for it in iterators)
if any(isinstance(v, _ZipSentinel) for v in tup):
raise ValueError(f"at least one of iterables was exhausted in {i + 1} < {n} iterations")
yield tup

@ -0,0 +1,8 @@
import pandas
from .common import zip_n
def describe_df(df: pandas.DataFrame) -> pandas.DataFrame:
df_items = df.items()
names, series = zip_n(*df_items, n=2)
return pandas.DataFrame(({'length': len(s), 'dtype': s.dtype} for s in series), index=names)

@ -0,0 +1,4 @@
from math import ceil, log
def suggest_bins_num(n: int) -> int:
return max(int(ceil(log(n))), 10)

@ -1,2 +1,4 @@
matplotlib ~=3.10
numpy ~=2.3
pandas ~=2.3
seaborn ~=0.13.2

Загрузка…
Отмена
Сохранить