# Core utilities built on pandas & numpy
from __future__ import annotations
import sys
import pandas as pd
import numpy as np

__version__ = '0.1.0'

def summarize_numeric(df: pd.DataFrame, cols=None) -> pd.DataFrame:
    if cols is None:
        cols = df.select_dtypes(include=[np.number]).columns.tolist()
    if not cols:
        raise ValueError('No numeric columns found to summarize.')
    desc = df[cols].describe().T
    desc.index.name = 'column'
    return desc.reset_index()

def _cli_summarize():
    if len(sys.argv) < 2:
        print('Usage: ka-summarize <csv-path> [comma,separated,columns]')
        raise SystemExit(2)
    path = sys.argv[1]
    cols = sys.argv[2].split(',') if len(sys.argv) > 2 else None
    df = pd.read_csv(path)
    out = summarize_numeric(df, cols)
    print(out.to_string(index=False))
