Series#

class Series#

One-dimensional labeled array capable of holding any data type.

Example#

import pandasCore as pd

# Create Series
s = pd.Series([1.0, 2.0, 3.0], name='values')
print(s.size)   # 3
print(s.dtype)  # float64

Attributes#

Attribute

Description

Example

T

Return the transpose (self for Series)

View

at

Access a single value for a row label. Returns dict for lookup.

View

cat

Accessor object for categorical properties.

View

dt

Accessor object for datetimelike properties.

View

dtype

Return the dtype object of the underlying data

View

empty

Indicator whether Series is empty

iat

Access a single value by integer position. Returns list for lookup.

View

iloc

Purely integer-location based indexing. Returns list for indexing.

View

index

The index (axis labels) of the Series

View

loc

Access a group of rows by label(s). Returns dict of {label: value} …

View

name

Return the name of the Series

View

nbytes

Return the number of bytes in the underlying data

View

ndim

Number of dimensions of the underlying data (always 1 for Series)

View

plot

Accessor for plot methods (requires matplotlib)

View

shape

Return a tuple of the shape of the underlying data

View

size

Return the number of elements in the underlying data

View

sparse

Accessor for sparse data operations.

View

str

Vectorized string functions for Series.

View

Construction#

Method

Description

Example

__init__() (data: object = None, index: object = None, dtype: object = None, name: object = None, copy: object = None, fastpath: object = None)

Create a Series from data.

View

Indexing / Selection#

Method

Description

Example

__getitem__() (key: typing.SupportsInt)

Get element by position

__setitem__() (key: typing.SupportsInt, value: typing.SupportsFloat)

Set element by position

first() (offset: str)

Select initial periods of time series data based on a date offset.

View

get() (key: str, default: object = None)

Get item from object for given key (ex: DataFrame column).

View

head() (n: typing.SupportsInt = 5)

Return the first n elements

View

idxmax() (axis: typing.SupportsInt = 0, skipna: bool = True, *args, **kwargs)

Return the index of the maximum value.

View

idxmin() (axis: typing.SupportsInt = 0, skipna: bool = True, *args, **kwargs)

Return the index of the minimum value.

View

last() (offset: str)

Select final periods of time series data based on a date offset.

View

mask() (cond: collections.abc.Sequence[bool], other: object = None, *, inplace: bool = False, axis: object = None, level: object = None)

Replace values where the condition is True.

View

nlargest() (n: typing.SupportsInt = 5, keep: str = 'first')

Return the largest n elements.

View

nsmallest() (n: typing.SupportsInt = 5, keep: str = 'first')

Return the smallest n elements.

View

sample() (n: object = None, frac: object = None, replace: bool = False, weights: object = None, random_state: object = None, axis: object = None, ignore_index: bool = False)

Return a random sample of items from an axis of object.

View

tail() (n: typing.SupportsInt = 5)

Return the last n elements

View

take() (indices: collections.abc.Sequence[typing.SupportsInt], axis: typing.SupportsInt = 0, **kwargs)

Return the elements in the given positional indices along an axis.

View

where() (cond: collections.abc.Sequence[bool], other: typing.SupportsFloat = nan, *, inplace: bool = False, axis: object = None, level: object = None)

Replace values where the condition is False.

View

xs() (key: str, axis: typing.SupportsInt = 0, level: object = None, drop_level: bool = True)

Return cross-section from the Series.

View

Data Manipulation#

Method

Description

Example

drop() (labels: object = None, *, axis: typing.SupportsInt = 0, index: object = None, columns: object = None, level: object = None, inplace: bool = False, errors: str = 'raise')

Return Series with specified index labels removed.

View

droplevel() (level: typing.SupportsInt, axis: typing.SupportsInt = 0)

Return Series with requested index level removed.

View

pop() (item: str)

Return item and drops from series.

View

reindex() (index: object = None, *, axis: object = None, method: object = None, copy: object = None, level: object = None, fill_value: object = None, limit: object = None, tolerance: object = None)

Conform Series to new index with optional filling logic.

View

rename() (index: object = None, *, axis: object = None, copy: object = None, inplace: bool = False, level: object = None, errors: str = 'ignore')

Alter Series name or index labels.

View

rename_axis() (mapper: object = None, *, index: object = None, axis: typing.SupportsInt = 0, copy: bool = True, inplace: bool = False)

Set the name of the axis (index).

View

reorder_levels() (order: collections.abc.Sequence[typing.SupportsInt])

Rearrange index levels using input order.

View

replace() (to_replace: object = None, value: object = None, *, inplace: bool = False, limit: object = None, regex: bool = False, method: object = None)

Replace values given in to_replace with value.

View

reset_index() (level: object = None, *, drop: bool = False, name: object = None, inplace: bool = False, allow_duplicates: bool = False)

Reset the index.

View

set_axis() (labels: collections.abc.Sequence[str], *, axis: typing.SupportsInt = 0, copy: object = None)

Assign desired index to given axis.

View

swaplevel() (i: typing.SupportsInt = -2, j: typing.SupportsInt = -1, copy: object = None)

Swap levels i and j in a MultiIndex.

View

update() (other: pandasCore.Series)

Modify Series in place using values from another Series.

Missing Data#

Method

Description

Example

backfill() (*, axis: object = None, inplace: bool = False, limit: object = None, downcast: object = None)

Alias for bfill. Fill NA/NaN values by using the next valid observa…

View

bfill() (*, axis: object = None, inplace: bool = False, limit: object = None, limit_area: object = None, downcast: object = None)

Fill NA/NaN values by using the next valid observation.

View

dropna() (*, axis: typing.SupportsInt = 0, inplace: bool = False, how: object = None, ignore_index: bool = False)

Return a new Series with missing values removed.

View

ffill() (*, axis: object = None, inplace: bool = False, limit: object = None, limit_area: object = None, downcast: object = None)

Fill NA/NaN values by propagating the last valid observation forward.

View

fillna() (value: object = None, *, method: object = None, axis: object = None, inplace: bool = False, limit: object = None, downcast: object = None)

Fill NA/NaN values using the specified method.

View

interpolate() (method: str = 'linear', *, axis: typing.SupportsInt = 0, limit: object = None, inplace: bool = False, limit_direction: object = None, limit_area: object = None, downcast: object = None, **kwargs)

Fill NaN values using interpolation.

View

isna() ()

Detect missing values.

View

isnull() ()

Alias for isna. Detect missing values.

View

notna() ()

Detect existing (non-missing) values.

View

notnull() ()

Alias for notna. Detect non-missing values.

View

pad() (*, axis: object = None, inplace: bool = False, limit: object = None, downcast: object = None)

Alias for ffill. Fill NA/NaN values by propagating the last valid o…

View

Statistics#

Method

Description

Example

count() ()

Return number of non-NA/null observations in the Series.

View

cummax() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return cumulative maximum over a DataFrame or Series axis.

View

cummin() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return cumulative minimum over a DataFrame or Series axis.

View

cumprod() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return cumulative product over a DataFrame or Series axis.

View

cumsum() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return cumulative sum over a DataFrame or Series axis.

View

describe() (percentiles: object = None, include: object = None, exclude: object = None)

Generate descriptive statistics.

View

kurt() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return unbiased kurtosis over requested axis.

View

kurtosis() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return unbiased kurtosis over requested axis. Alias for kurt.

View

max() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return the maximum of the values over the requested axis.

View

mean() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return the mean of the values over the requested axis.

View

median() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return the median of the values over the requested axis.

View

min() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return the minimum of the values over the requested axis.

View

mode() (dropna: bool = True)

Return the mode(s) of the Series.

View

nunique() (dropna: bool = True)

Return number of unique elements.

View

prod() (axis: object = None, skipna: bool = True, numeric_only: bool = False, min_count: typing.SupportsInt = 0, **kwargs)

Return the product of the values over the requested axis.

View

quantile() (q: typing.SupportsFloat = 0.5, interpolation: str = 'linear')

Return value at the given quantile.

View

sem() (axis: object = None, skipna: bool = True, ddof: typing.SupportsInt = 1, numeric_only: bool = False, **kwargs)

Return unbiased standard error of the mean over requested axis.

View

skew() (axis: object = 0, skipna: bool = True, numeric_only: bool = False, **kwargs)

Return unbiased skew over requested axis.

View

std() (axis: object = None, skipna: bool = True, ddof: typing.SupportsInt = 1, numeric_only: bool = False, **kwargs)

Return sample standard deviation over requested axis.

View

sum() (axis: object = None, skipna: bool = True, numeric_only: bool = False, min_count: typing.SupportsInt = 0, **kwargs)

Return the sum of the values over the requested axis.

View

value_counts() (normalize: bool = False, sort: bool = True, ascending: bool = False, bins: object = None, dropna: bool = True)

Return a Series containing counts of unique values.

View

var() (axis: object = None, skipna: bool = True, ddof: typing.SupportsInt = 1, numeric_only: bool = False, **kwargs)

Return unbiased variance over requested axis.

View

Aggregation#

Method

Description

Example

agg() (func: object = None, axis: typing.SupportsInt = 0, *args, **kwargs)

Aggregate using one or more operations over the specified axis.

View

aggregate() (func: object = None, axis: typing.SupportsInt = 0, *args, **kwargs)

Aggregate using one or more operations over the specified axis. Ali…

View

apply() (func: object, convert_dtype: object = None, args: object = (), *, by_row: object = 'compat', **kwargs)

Invoke function on values of Series.

View

ewm() (com: object = None, span: object = None, halflife: object = None, alpha: object = None, min_periods: object = 0, adjust: bool = True, ignore_na: bool = False, axis: object = None, times: object = None, method: str = 'single')

Provide exponentially weighted (EW) calculations.

View

expanding() (min_periods: typing.SupportsInt = 1, axis: object = None, method: str = 'single')

Provide expanding window calculations.

View

groupby() (by: object = None, axis: typing.SupportsInt = 0, level: object = None, as_index: bool = True, sort: bool = True, group_keys: bool = True, observed: object = None, dropna: bool = True)

Group Series using a mapper or by a Series of columns.

View

map() (arg: object, na_action: object = None)

Map values of Series according to an input mapping or function.

View

pipe() (func: object, *args, **kwargs)

Apply chainable functions that expect Series.

View

resample() (rule: str, axis: object = None, closed: object = None, label: object = None, convention: object = None, kind: object = None, on: object = None, level: object = None, origin: str = 'start_day', offset: object = None, group_keys: bool = False)

Resample time-series data.

View

rolling() (window: object, min_periods: object = None, center: bool = False, win_type: object = None, on: object = None, axis: object = None, closed: object = None, step: object = None, method: str = 'single')

Provide rolling window calculations.

View

transform() (func: object, axis: typing.SupportsInt = 0, *args, **kwargs)

Call func on self producing a Series with the same axis shape as self.

View

Arithmetic#

Method

Description

Example

add() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Addition of series and other, element-wise.

View

div() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Floating division of series and other, element-wise.

View

dot() (other: object)

Compute the dot product between the Series and another.

floordiv() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Integer division of series and other, element-wise.

View

mod() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Modulo of series and other, element-wise.

View

mul() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Multiplication of series and other, element-wise.

View

pow() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Exponential power of series and other, element-wise.

View

radd() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse addition of series and other, element-wise (other + …

View

rdiv() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse division of series and other, element-wise (other / …

View

rfloordiv() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse integer division of series and other, element-wise (…

View

rmod() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse modulo of series and other, element-wise (other % se…

View

rmul() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse multiplication of series and other, element-wise (ot…

View

rpow() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse power of series and other, element-wise (other ** se…

View

rsub() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse subtraction of series and other, element-wise (other…

View

rtruediv() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Reverse true division of series and other, element-wise (oth…

sub() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Subtraction of series and other, element-wise.

View

truediv() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return True division of series and other, element-wise.

View

Comparison#

Method

Description

Example

__eq__() (self, value, /)

Return self==value.

__ge__() (arg0: object)

__gt__() (arg0: object)

__le__() (arg0: object)

__lt__() (arg0: object)

__ne__() (self, value, /)

Return self!=value.

compare() (other: pandasCore.Series, align_axis: typing.SupportsInt = 1, keep_shape: bool = False, keep_equal: bool = False, result_names: tuple[str, str] = ('self', 'other'))

Compare to another Series and show the differences.

eq() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Equal to of series and other, element-wise.

View

equals() (other: pandasCore.Series)

Test whether two objects contain the same elements.

ge() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Greater than or equal to of series and other, element-wise.

View

gt() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Greater than of series and other, element-wise.

View

le() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Less than or equal to of series and other, element-wise.

View

lt() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Less than of series and other, element-wise.

View

ne() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Not equal to of series and other, element-wise.

View

Sorting#

Method

Description

Example

argsort() (axis: typing.SupportsInt = 0, kind: str = 'quicksort', order: object = None, stable: object = None)

Return the integer indices that would sort the Series values.

View

rank() (axis: typing.SupportsInt = 0, method: str = 'average', numeric_only: bool = False, na_option: str = 'keep', ascending: bool = True, pct: bool = False)

Compute numerical data ranks (1 through n) along axis.

View

searchsorted() (value: typing.SupportsFloat, side: str = 'left', sorter: object = None)

Find indices where elements should be inserted to maintain order.

View

sort_index() (*, axis: typing.SupportsInt = 0, level: object = None, ascending: bool = True, inplace: bool = False, kind: str = 'quicksort', na_position: str = 'last', sort_remaining: bool = True, ignore_index: bool = False, key: object = None)

Sort object by labels (along an axis).

View

sort_values() (*, axis: typing.SupportsInt = 0, ascending: bool = True, inplace: bool = False, kind: str = 'quicksort', na_position: str = 'last', ignore_index: bool = False, key: object = None)

Sort by the values.

View

Reshaping#

Method

Description

Example

explode() (ignore_index: bool = False)

Transform each element of a list-like to a row.

View

squeeze() (axis: object = None)

Squeeze 1 dimensional axis objects into scalars.

swapaxes() (axis1: typing.SupportsInt, axis2: typing.SupportsInt, copy: object = None)

Interchange axes and swap values axes appropriately.

View

to_frame() (name: object = None)

Convert Series to DataFrame.

View

transpose() (*args, **kwargs)

Return the transpose, which is by definition self.

View

unstack() (level: object = -1, fill_value: object = None, sort: bool = True)

Unstack, also known as pivot, Series with MultiIndex to produce Dat…

View

Combining#

Method

Description

Example

align() (other: pandasCore.Series, join: str = 'outer', axis: object = None, level: object = None, copy: object = None, fill_value: object = None, method: object = None, limit: object = None, fill_axis: object = None, broadcast_axis: object = None)

Align two objects on their axes with the specified join method.

combine() (other: pandasCore.Series, func: collections.abc.Callable, fill_value: object = None)

Combine the Series with another Series.

combine_first() (other: pandasCore.Series)

Update null elements with value in the same location in other.

Time Series#

Method

Description

Example

asfreq() (freq: str, method: object = None, how: object = None, normalize: bool = False, fill_value: object = None)

Convert time series to specified frequency.

View

asof() (where: object, subset: object = None)

Return the last row(s) without any NaNs before where.

View

at_time() (time: str, asof: bool = False, axis: object = None)

Select values at particular time of day (e.g., 9:30AM).

View

between_time() (start_time: str, end_time: str, inclusive: str = 'both', axis: object = None)

Select values between particular times of the day.

View

diff() (periods: typing.SupportsInt = 1)

First discrete difference of element.

View

first_valid_index() ()

Return index for first non-NA value or None, if no non-NA value is …

View

last_valid_index() ()

Return index for last non-NA value or None, if no non-NA value is f…

View

pct_change() (periods: typing.SupportsInt = 1, fill_method: object = None, limit: object = None, freq: object = None, **kwargs)

Percentage change between the current and a prior element.

View

shift() (periods: typing.SupportsInt = 1, freq: object = None, axis: typing.SupportsInt = 0, fill_value: object = None, suffix: object = None)

Shift index by desired number of periods.

View

to_period() (freq: object = None, copy: object = None)

Convert Series from DatetimeIndex to PeriodIndex.

View

to_timestamp() (freq: object = None, how: str = 'start', copy: object = None)

Cast to DatetimeIndex of timestamps.

View

tz_convert() (tz: str, axis: typing.SupportsInt = 0, level: object = None, copy: object = None)

Convert tz-aware axis to target time zone.

View

tz_localize() (tz: object, axis: typing.SupportsInt = 0, level: object = None, copy: object = None, ambiguous: str = 'raise', nonexistent: str = 'raise')

Localize tz-naive index of a Series to target time zone.

View

I/O#

Method

Description

Example

to_clipboard() (*, excel: bool = True, sep: object = None, **kwargs)

Copy object to the system clipboard.

to_csv() (path_or_buf: object = None, *, sep: str = ',', na_rep: str = '', float_format: object = None, columns: object = None, header: bool = True, index: bool = True, index_label: object = None, mode: str = 'w', encoding: object = None, compression: object = 'infer', quoting: object = None, quotechar: str = '"', lineterminator: object = None, chunksize: object = None, date_format: object = None, doublequote: bool = True, escapechar: object = None, decimal: str = '.', errors: str = 'strict', storage_options: object = None)

Write object to a comma-separated values (csv) file.

View

to_dict() (*, into: object = None)

Convert Series to dict.

View

to_excel() (excel_writer: object, *, sheet_name: str = 'Sheet1', na_rep: str = '', float_format: object = None, columns: object = None, header: object = True, index: bool = True, index_label: object = None, startrow: typing.SupportsInt = 0, startcol: typing.SupportsInt = 0, engine: object = None, merge_cells: bool = True, inf_rep: str = 'inf', freeze_panes: object = None, storage_options: object = None, engine_kwargs: object = None)

Write object to an Excel sheet.

to_hdf() (path_or_buf: str, *, key: str, mode: str = 'a', complevel: object = None, complib: object = None, append: bool = False, format: object = None, index: bool = True, min_itemsize: object = None, nan_rep: object = None, dropna: object = None, data_columns: object = None, errors: str = 'strict', encoding: str = 'UTF-8')

Write the contained data to an HDF5 file using HDFStore.

to_json() (path_or_buf: object = None, *, orient: object = None, date_format: object = None, double_precision: typing.SupportsInt = 10, force_ascii: bool = True, date_unit: str = 'ms', default_handler: object = None, lines: bool = False, compression: object = 'infer', index: object = None, indent: object = None, storage_options: object = None, mode: str = 'w')

Convert the object to a JSON string.

View

to_latex() (buf: object = None, *, columns: object = None, header: bool = True, index: bool = True, na_rep: str = 'NaN', formatters: object = None, float_format: object = None, sparsify: object = None, index_names: bool = True, bold_rows: bool = False, column_format: object = None, longtable: object = None, escape: object = None, encoding: object = None, decimal: str = '.', multicolumn: object = None, multicolumn_format: object = None, multirow: object = None, caption: object = None, label: object = None, position: object = None)

Render object to a LaTeX tabular environment table.

View

to_list() ()

Return a list of the values

View

to_markdown() (buf: object = None, mode: str = 'wt', index: bool = True, storage_options: object = None, **kwargs)

Print Series in Markdown-friendly format.

View

to_numpy() (dtype: object = None, copy: bool = False, na_value: object = None, **kwargs)

A NumPy ndarray representing the values in this Series.

View

to_pickle() (path: str, *, compression: str = 'infer', protocol: typing.SupportsInt = 5, storage_options: object = None)

Pickle (serialize) object to file.

to_sql() (name: str, con: object, *, schema: object = None, if_exists: str = 'fail', index: bool = True, index_label: object = None, chunksize: object = None, dtype: object = None, method: object = None)

Write records stored in a DataFrame to a SQL database.

to_string() (buf: object = None, na_rep: str = 'NaN', float_format: object = None, header: bool = True, index: bool = True, length: bool = False, dtype: bool = False, name: bool = False, max_rows: object = None, min_rows: object = None)

Render a string representation of the Series.

View

to_xarray() ()

Return an xarray object from the pandas object.

tolist() ()

Return a list of the values (alias for to_list)

View

Conversion#

Method

Description

Example

astype() (dtype: str, copy: object = None, errors: str = 'raise')

Cast a pandas object to a specified dtype.

View

bool() ()

Return the bool of a single element Series.

View

convert_dtypes() (infer_objects: bool = True, convert_string: bool = True, convert_integer: bool = True, convert_boolean: bool = True, convert_floating: bool = True, dtype_backend: str = 'numpy_nullable')

Convert columns to the best possible dtypes using dtypes supporting…

View

copy() (deep: bool = True)

Make a copy of this object’s indices and data.

View

infer_objects() (copy: object = None)

Attempt to infer better dtypes for object columns.

View

view() (dtype: object = None)

Create a new view of the Series.

View

Iteration#

Method

Description

Example

__contains__() (item: typing.SupportsFloat)

Return True if value is in Series

__iter__() ()

Iterate over values

__len__() ()

Return the number of elements

items() ()

Lazily iterate over (index, value) tuples.

View

keys() ()

Return alias for index.

View

Set Operations#

Method

Description

Example

drop_duplicates() (*, keep: str = 'first', inplace: bool = False, ignore_index: bool = False)

Return Series with duplicate values removed.

View

duplicated() (keep: str = 'first')

Indicate duplicate Series values.

View

isin() (values: collections.abc.Sequence[typing.SupportsFloat])

Check whether each element is in values.

View

unique() ()

Return unique values of Series.

View

Datetime Methods#

Method

Description

Example

round() (decimals: typing.SupportsInt = 0, *args, **kwargs)

Round each value to the given number of decimals.

View

Other Methods#

Method

Description

Example

__hash__() (self, /)

Return hash(self).

__repr__() ()

__str__() ()

abs() ()

Return a Series with absolute numeric value of each element.

View

add_prefix() (prefix: str, axis: object = None)

Prefix labels with string prefix.

View

add_suffix() (suffix: str, axis: object = None)

Suffix labels with string suffix.

View

all() (axis: object = 0, bool_only: bool = False, skipna: bool = True, **kwargs)

Return whether all elements are True, potentially over an axis.

View

any() (*, axis: typing.SupportsInt = 0, bool_only: bool = False, skipna: bool = True, **kwargs)

Return whether any element is True, potentially over an axis.

View

argmax() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return int position of the maximum value.

View

argmin() (axis: object = None, skipna: bool = True, *args, **kwargs)

Return int position of the minimum value.

View

autocorr() (lag: typing.SupportsInt = 1)

Compute the lag-N autocorrelation.

View

between() (left: typing.SupportsFloat, right: typing.SupportsFloat, inclusive: str = 'both')

Return boolean Series equivalent to left <= series <= right.

View

case_when() (caselist: object)

Replace values where the conditions are True.

View

clip() (lower: object = None, upper: object = None, *, axis: object = None, inplace: bool = False, **kwargs)

Trim values at input threshold(s).

View

corr() (other: pandasCore.Series, method: str = 'pearson', min_periods: object = None)

Compute correlation with other Series.

cov() (other: pandasCore.Series, min_periods: object = None, ddof: typing.SupportsInt = 1)

Compute covariance with other Series.

divide() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Division of series and other, element-wise.

View

divmod() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return integer division and modulo of series and other, element-wise.

View

factorize() (sort: bool = False, use_na_sentinel: bool = True)

Encode the object as an enumerated type.

View

filter() (items: object = None, like: object = None, regex: object = None, axis: object = None)

Subset the dataframe rows or columns according to the specified ind…

View

hist() (by: object = None, ax: object = None, grid: bool = True, xlabelsize: object = None, xrot: object = None, ylabelsize: object = None, yrot: object = None, figsize: object = None, bins: typing.SupportsInt = 10, backend: object = None, legend: bool = False, **kwargs)

Draw histogram of the input series using matplotlib.

View

info() (verbose: object = None, buf: object = None, max_cols: object = None, memory_usage: object = None, show_counts: bool = True)

Print a concise summary of a Series.

View

item() ()

Return the first element of the underlying data as a Python scalar.

View

memory_usage() (index: bool = True, deep: bool = False)

Return the memory usage of the Series.

View

multiply() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Multiplication of series and other, element-wise.

View

product() (axis: object = None, skipna: bool = True, numeric_only: bool = False, min_count: typing.SupportsInt = 0, **kwargs)

Return the product of the values over the requested axis. Alias for…

View

ravel() (order: str = 'C')

Return the flattened underlying data as an ndarray or ExtensionArray.

View

rdivmod() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return reverse integer division and modulo of series and other, ele…

View

reindex_like() (other: pandasCore.Series, method: object = None, copy: object = None, limit: object = None, tolerance: object = None)

Return a Series with matching index as other object.

repeat() (repeats: typing.SupportsInt, axis: object = None)

Repeat elements of a Series.

View

set_flags() (*, copy: bool = False, allows_duplicate_labels: object = None)

Return a new object with updated flags.

View

subtract() (other: object, level: object = None, fill_value: object = None, axis: typing.SupportsInt = 0)

Return Subtraction of series and other, element-wise.

View

truncate() (before: object = None, after: object = None, axis: object = None, copy: object = None)

Truncate a Series before and after some index value.

View

values() ()

Return Series as ndarray or ndarray-like

View

Code Examples#

The following examples are extracted from the test suite.

T (test_series_phase5.py:214)
204    try:
205        s = pandasCore.Series([1.0, 2.0, 3.0])
206
207        # transpose is no-op for Series
208        transposed = s.transpose()
209        assert transposed.to_list() == s.to_list(), "transpose should return same values"
210        f_print_info(f"  transpose(): {transposed.to_list()}")
211
212        # T property
213        transposed = s.T
214        assert transposed.to_list() == s.to_list(), "T property should return same values"
215        f_print_info(f"  .T property: {transposed.to_list()}")
216
217        f_print_success("Series transpose: passed")
218        return True
219    except Exception as e:
220        f_print_error(f"Series transpose failed: {e}")
221        return False
at (test_series_phase5.py:679)
669        assert loc_result["0"] == 1.0, "loc['0'] should be 1.0"
670        f_print_info(f"  loc: {loc_result}")
671
672        # iloc returns list
673        iloc_result = s.iloc
674        assert isinstance(iloc_result, list), "iloc should return list"
675        assert iloc_result[0] == 1.0, "iloc[0] should be 1.0"
676        f_print_info(f"  iloc: {iloc_result}")
677
678        # at returns dict
679        at_result = s.at
680        assert isinstance(at_result, dict), "at should return dict"
681        f_print_info(f"  at: {at_result}")
682
683        # iat returns list
684        iat_result = s.iat
685        assert isinstance(iat_result, list), "iat should return list"
686        f_print_info(f"  iat: {iat_result}")
687
688        f_print_success("Series loc/iloc/at/iat: passed")
689        return True
cat (test_accessor_descriptor.py:208)
198    """Test that StringSeries.cat accessor works on instance"""
199    f_print_header("Test: StringSeries instance cat accessor")
200
201    try:
202        # Create StringSeries
203        data = ["apple", "banana", "apple", "cherry"]
204        s = pandasCore.StringSeries(data, name="fruits")
205        f_print_success(f"Created StringSeries: {s.values()}")
206
207        # Access .cat on instance should return CategoricalAccessor
208        cat_accessor = s.cat
209        type_name = type(cat_accessor).__name__
210        f_print_info(f"type(s.cat).__name__ = {type_name}")
211
212        if type_name == "CategoricalAccessor":
213            f_print_success("s.cat returns CategoricalAccessor")
214        else:
215            f_print_error(f"Expected CategoricalAccessor, got {type_name}")
216            return False
217
218        # Test categories property
dt (test_accessor_descriptor.py:240)
230    """Test that DatetimeSeries.dt accessor works on instance"""
231    f_print_header("Test: DatetimeSeries instance dt accessor")
232
233    try:
234        # Create DatetimeSeries
235        data = ["2024-01-15", "2024-06-20", "2024-12-25"]
236        s = pandasCore.DatetimeSeries(data)
237        f_print_success(f"Created DatetimeSeries with {len(s)} elements")
238
239        # Access .dt on instance should return DatetimeProperties
240        dt_accessor = s.dt
241        type_name = type(dt_accessor).__name__
242        f_print_info(f"type(s.dt).__name__ = {type_name}")
243
244        if type_name == "DatetimeProperties":
245            f_print_success("s.dt returns DatetimeProperties")
246        else:
247            f_print_error(f"Expected DatetimeProperties, got {type_name}")
248            return False
249
250        # Test year property
dtype (test_example.py:114)
104            return False
105
106        # Check name
107        if s.name == "test_series":
108            f_print_success(f"Name is correct: {s.name}")
109        else:
110            f_print_error(f"Name is wrong: {s.name}, expected 'test_series'")
111            return False
112
113        # Check dtype
114        if s.dtype == "float64":
115            f_print_success(f"Dtype is correct: {s.dtype}")
116        else:
117            f_print_error(f"Dtype is wrong: {s.dtype}, expected 'float64'")
118            return False
119
120        # Check values
121        values = s.values()
122        if values == data:
123            f_print_success(f"Values are correct: {values}")
124        else:
iat (test_series_phase5.py:684)
674        assert isinstance(iloc_result, list), "iloc should return list"
675        assert iloc_result[0] == 1.0, "iloc[0] should be 1.0"
676        f_print_info(f"  iloc: {iloc_result}")
677
678        # at returns dict
679        at_result = s.at
680        assert isinstance(at_result, dict), "at should return dict"
681        f_print_info(f"  at: {at_result}")
682
683        # iat returns list
684        iat_result = s.iat
685        assert isinstance(iat_result, list), "iat should return list"
686        f_print_info(f"  iat: {iat_result}")
687
688        f_print_success("Series loc/iloc/at/iat: passed")
689        return True
690    except Exception as e:
691        f_print_error(f"Series loc/iloc/at/iat failed: {e}")
692        return False
iloc (test_series_phase5.py:673)
663    try:
664        s = pandasCore.Series([1.0, 2.0, 3.0])
665
666        # loc returns dict
667        loc_result = s.loc
668        assert isinstance(loc_result, dict), "loc should return dict"
669        assert loc_result["0"] == 1.0, "loc['0'] should be 1.0"
670        f_print_info(f"  loc: {loc_result}")
671
672        # iloc returns list
673        iloc_result = s.iloc
674        assert isinstance(iloc_result, list), "iloc should return list"
675        assert iloc_result[0] == 1.0, "iloc[0] should be 1.0"
676        f_print_info(f"  iloc: {iloc_result}")
677
678        # at returns dict
679        at_result = s.at
680        assert isinstance(at_result, dict), "at should return dict"
681        f_print_info(f"  at: {at_result}")
682
683        # iat returns list
index (test_series.py:547)
537        # shape
538        assert s.shape == (3,), f"Expected shape (3,), got {s.shape}"
539
540        # ndim
541        assert s.ndim == 1, f"Expected ndim=1, got {s.ndim}"
542
543        # nbytes
544        assert s.nbytes > 0, f"Expected positive nbytes, got {s.nbytes}"
545
546        # index
547        idx = s.index
548        assert len(idx) == 3, f"Expected 3 index entries, got {len(idx)}"
549
550        f_print_success("Series properties: passed")
551        return True
552    except Exception as e:
553        f_print_error(f"Series properties failed: {e}")
554        return False
555
556
557def f_main():
loc (test_series_phase5.py:667)
657def test_loc_iloc_at_iat():
658    """Test Series loc, iloc, at, iat properties"""
659    f_print_header("Test: Series loc/iloc/at/iat")
660
661    try:
662        s = pandasCore.Series([1.0, 2.0, 3.0])
663
664        # loc returns dict
665        loc_result = s.loc
666        assert isinstance(loc_result, dict), "loc should return dict"
667        assert loc_result["0"] == 1.0, "loc['0'] should be 1.0"
668        f_print_info(f"  loc: {loc_result}")
669
670        # iloc returns list
671        iloc_result = s.iloc
672        assert isinstance(iloc_result, list), "iloc should return list"
673        assert iloc_result[0] == 1.0, "iloc[0] should be 1.0"
674        f_print_info(f"  iloc: {iloc_result}")
name (test_example.py:107)
 97        f_print_success("Created Series from list")
 98
 99        # Check size
100        if s.size == 5:
101            f_print_success(f"Size is correct: {s.size}")
102        else:
103            f_print_error(f"Size is wrong: {s.size}, expected 5")
104            return False
105
106        # Check name
107        if s.name == "test_series":
108            f_print_success(f"Name is correct: {s.name}")
109        else:
110            f_print_error(f"Name is wrong: {s.name}, expected 'test_series'")
111            return False
112
113        # Check dtype
114        if s.dtype == "float64":
115            f_print_success(f"Dtype is correct: {s.dtype}")
116        else:
117            f_print_error(f"Dtype is wrong: {s.dtype}, expected 'float64'")
nbytes (test_series.py:544)
534    try:
535        s = pandasCore.Series([1.0, 2.0, 3.0], name="test")
536
537        # shape
538        assert s.shape == (3,), f"Expected shape (3,), got {s.shape}"
539
540        # ndim
541        assert s.ndim == 1, f"Expected ndim=1, got {s.ndim}"
542
543        # nbytes
544        assert s.nbytes > 0, f"Expected positive nbytes, got {s.nbytes}"
545
546        # index
547        idx = s.index
548        assert len(idx) == 3, f"Expected 3 index entries, got {len(idx)}"
549
550        f_print_success("Series properties: passed")
551        return True
552    except Exception as e:
553        f_print_error(f"Series properties failed: {e}")
554        return False
ndim (test_series.py:541)
531    """Test Series properties (shape, ndim, nbytes, index)"""
532    f_print_header("Test: Series properties")
533
534    try:
535        s = pandasCore.Series([1.0, 2.0, 3.0], name="test")
536
537        # shape
538        assert s.shape == (3,), f"Expected shape (3,), got {s.shape}"
539
540        # ndim
541        assert s.ndim == 1, f"Expected ndim=1, got {s.ndim}"
542
543        # nbytes
544        assert s.nbytes > 0, f"Expected positive nbytes, got {s.nbytes}"
545
546        # index
547        idx = s.index
548        assert len(idx) == 3, f"Expected 3 index entries, got {len(idx)}"
549
550        f_print_success("Series properties: passed")
551        return True
plot (test_series_phase5.py:623)
613        # (unlike pandas which requires SparseDtype)
614        try:
615            sparse_acc = s.sparse
616            f_print_info("  sparse accessor: available (pandasCore extension)")
617        except RuntimeError as e:
618            f_print_error("sparse accessor should work on float64 Series in pandasCore")
619            return False
620
621        # plot accessor should raise
622        try:
623            _ = s.plot
624            f_print_error("plot accessor should raise error")
625            return False
626        except RuntimeError as e:
627            f_print_info("  plot accessor: raises expected error")
628
629        f_print_success("Series accessor errors: passed")
630        return True
631    except Exception as e:
632        f_print_error(f"Series accessor errors failed: {e}")
633        return False
shape (test_series.py:538)
528def test_series_properties():
529    """Test Series properties (shape, ndim, nbytes, index)"""
530    f_print_header("Test: Series properties")
531
532    try:
533        s = pandasCore.Series([1.0, 2.0, 3.0], name="test")
534
535        # shape
536        assert s.shape == (3,), f"Expected shape (3,), got {s.shape}"
537
538        # ndim
539        assert s.ndim == 1, f"Expected ndim=1, got {s.ndim}"
540
541        # nbytes
542        assert s.nbytes > 0, f"Expected positive nbytes, got {s.nbytes}"
543
544        # index
545        idx = s.index
546        assert len(idx) == 3, f"Expected 3 index entries, got {len(idx)}"
size (test_example.py:100)
 90    """Test Series creation from list"""
 91    f_print_header("Test: Series Creation")
 92
 93    try:
 94        # Create Series from list
 95        data = [1.0, 2.0, 3.0, 4.0, 5.0]
 96        s = pandasCore.Series(data, name="test_series")
 97        f_print_success("Created Series from list")
 98
 99        # Check size
100        if s.size == 5:
101            f_print_success(f"Size is correct: {s.size}")
102        else:
103            f_print_error(f"Size is wrong: {s.size}, expected 5")
104            return False
105
106        # Check name
107        if s.name == "test_series":
108            f_print_success(f"Name is correct: {s.name}")
109        else:
110            f_print_error(f"Name is wrong: {s.name}, expected 'test_series'")
sparse (test_series_phase5.py:615)
605        try:
606            _ = s.cat
607            f_print_error("cat accessor should raise error for float64 Series")
608            return False
609        except RuntimeError as e:
610            f_print_info("  cat accessor: raises expected error")
611
612        # sparse accessor - in our implementation, works on any float64 Series
613        # (unlike pandas which requires SparseDtype)
614        try:
615            sparse_acc = s.sparse
616            f_print_info("  sparse accessor: available (pandasCore extension)")
617        except RuntimeError as e:
618            f_print_error("sparse accessor should work on float64 Series in pandasCore")
619            return False
620
621        # plot accessor should raise
622        try:
623            _ = s.plot
624            f_print_error("plot accessor should raise error")
625            return False
str (test_accessor_descriptor.py:114)
104    """Test that StringSeries.str accessor works on instance"""
105    f_print_header("Test: StringSeries instance str accessor")
106
107    try:
108        # Create StringSeries
109        data = ["HELLO", "world", "Test"]
110        s = pandasCore.StringSeries(data, name="test_strings")
111        f_print_success(f"Created StringSeries: {s.values()}")
112
113        # Access .str on instance should return StringAccessor
114        str_accessor = s.str
115        type_name = type(str_accessor).__name__
116        f_print_info(f"type(s.str).__name__ = {type_name}")
117
118        if type_name == "StringAccessor":
119            f_print_success("s.str returns StringAccessor")
120        else:
121            f_print_error(f"Expected StringAccessor, got {type_name}")
122            return False
123
124        # Test a string method
__init__ (test_concat_comp.py:318)
308# ==================== concat Series Tests ====================
309
310def test_concat_series_axis0():
311    """Test concat Series axis=0 (vertical stack)"""
312    f_print_header("concat Series axis=0")
313
314    pd_s1 = pd.Series([1.0, 2.0, 3.0])
315    pd_s2 = pd.Series([4.0, 5.0])
316    pd_result = pd.concat([pd_s1, pd_s2])
317
318    pc_s1 = pandasCore.Series([1.0, 2.0, 3.0])
319    pc_s2 = pandasCore.Series([4.0, 5.0])
320    pc_result = pandasCore.concat([pc_s1, pc_s2])
321
322    ctx.assert_equal(len(pd_result), len(pc_result), "Series axis=0 length")
323    ctx.assert_equal(5, len(pc_result), "Series axis=0 has 5 rows")
324
325
326def test_concat_series_axis1():
327    """Test concat named Series axis=1 (horizontal join)"""
328    f_print_header("concat Series axis=1")
first (test_series_phase5.py:504)
494def test_first_last():
495    """Test Series first and last methods"""
496    f_print_header("Test: Series first/last")
497
498    try:
499        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
500
501        # first returns head(1)
502        result = s.first("1D")
503        assert len(result) == 1, f"first should return 1 item"
504        f_print_info(f"  first('1D'): {result.to_list()}")
505
506        # last returns tail(1)
507        result = s.last("1D")
508        assert len(result) == 1, f"last should return 1 item"
509        f_print_info(f"  last('1D'): {result.to_list()}")
510
511        f_print_success("Series first/last: passed")
512        return True
get (test_series.py:166)
156def test_series_get():
157    """Test Series get method"""
158    f_print_header("Test: Series get")
159
160    try:
161        s = pandasCore.Series([1.0, 2.0, 3.0])
162
163        # Test get existing key
164        val = s.get("0")
165        assert val == 1.0, f"Expected 1.0, got {val}"
166
167        # Test get with default for non-existent key
168        val = s.get("999", default=99.0)
169        assert val == 99.0, f"Expected default 99.0, got {val}"
170
171        f_print_success("Series get: passed")
172        return True
173    except Exception as e:
174        f_print_error(f"Series get failed: {e}")
head (test_series.py:55)
45def test_series_head():
46    """Test Series head method"""
47    f_print_header("Test: Series head")
48
49    try:
50        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])
51
52        # Test default n=5
53        head = s.head()
54        assert len(head) == 5, f"Expected 5 elements, got {len(head)}"
55        assert head.to_list() == [1.0, 2.0, 3.0, 4.0, 5.0], "head(5) values incorrect"
56
57        # Test custom n=3
58        head = s.head(3)
59        assert len(head) == 3, f"Expected 3 elements, got {len(head)}"
60        assert head.to_list() == [1.0, 2.0, 3.0], "head(3) values incorrect"
61
62        f_print_success("Series head: passed")
63        return True
idxmax (test_series_phase3.py:243)
233        return True
234    except Exception as e:
235        f_print_error(f"describe: {e}")
236        return False
237
238
239def test_idxmax():
240    """Test Series.idxmax()"""
241    f_print_header("Test: idxmax")
242    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
243    result = s.idxmax()
244    # Index of 5.0 is "2" (position 2)
245    f_print_success(f"idxmax: {result}")
246    return True
247
248
249def test_idxmin():
250    """Test Series.idxmin()"""
251    f_print_header("Test: idxmin")
252    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
253    result = s.idxmin()
idxmin (test_series_phase3.py:253)
243    result = s.idxmax()
244    # Index of 5.0 is "2" (position 2)
245    f_print_success(f"idxmax: {result}")
246    return True
247
248
249def test_idxmin():
250    """Test Series.idxmin()"""
251    f_print_header("Test: idxmin")
252    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
253    result = s.idxmin()
254    # Index of 1.0 is "1" (position 1)
255    f_print_success(f"idxmin: {result}")
256    return True
257
258
259def test_argmax():
260    """Test Series.argmax()"""
261    f_print_header("Test: argmax")
262    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
263    result = s.argmax()
last (test_series_phase5.py:509)
499    try:
500        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
501
502        # first returns head(1)
503        result = s.first("1D")
504        assert len(result) == 1, f"first should return 1 item"
505        f_print_info(f"  first('1D'): {result.to_list()}")
506
507        # last returns tail(1)
508        result = s.last("1D")
509        assert len(result) == 1, f"last should return 1 item"
510        f_print_info(f"  last('1D'): {result.to_list()}")
511
512        f_print_success("Series first/last: passed")
513        return True
514    except Exception as e:
515        f_print_error(f"Series first/last failed: {e}")
516        return False
mask (test_series_phase2.py:605)
595def test_mask():
596    """Test Series mask method"""
597    f_print_header("Test: Series mask")
598
599    try:
600        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
601
602        # Replace values where condition is True
603        cond = [True, False, True, False, True]
604        s_mask = s.mask(cond, other=0.0)
605        expected = [0.0, 2.0, 0.0, 4.0, 0.0]
606        assert s_mask.to_list() == expected, f"Expected {expected}, got {s_mask.to_list()}"
607
608        f_print_success("mask: passed")
609        return True
610    except Exception as e:
611        f_print_error(f"mask failed: {e}")
612        return False
nlargest (test_series_phase3.py:421)
411    values = result.values()
412    # With method='average': 1.0 gets rank 1.5, 3.0 gets rank 3, 4.0 gets rank 4, 5.0 gets rank 5
413    f_print_success(f"rank: {values}")
414    return True
415
416
417def test_nlargest():
418    """Test Series.nlargest()"""
419    f_print_header("Test: nlargest")
420    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0, 9.0, 2.0, 6.0])
421    result = s.nlargest(3)
422    values = result.values()
423    if set(values) == {9.0, 6.0, 5.0}:
424        f_print_success(f"nlargest(3): {values} contains 9.0, 6.0, 5.0")
425        return True
426    f_print_error(f"nlargest(3): {values} incorrect")
427    return False
428
429
430def test_nsmallest():
431    """Test Series.nsmallest()"""
nsmallest (test_series_phase3.py:434)
424        f_print_success(f"nlargest(3): {values} contains 9.0, 6.0, 5.0")
425        return True
426    f_print_error(f"nlargest(3): {values} incorrect")
427    return False
428
429
430def test_nsmallest():
431    """Test Series.nsmallest()"""
432    f_print_header("Test: nsmallest")
433    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0, 9.0, 2.0, 6.0])
434    result = s.nsmallest(3)
435    values = result.values()
436    if set(values) == {1.0, 1.0, 2.0}:
437        f_print_success(f"nsmallest(3): {values} contains 1.0, 1.0, 2.0")
438        return True
439    f_print_error(f"nsmallest(3): {values} incorrect")
440    return False
441
442
443def test_value_counts():
444    """Test Series.value_counts()"""
sample (test_series_phase5.py:457)
447# ============================================================================
448
449def test_sample():
450    """Test Series sample method"""
451    f_print_header("Test: Series sample")
452
453    try:
454        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
455
456        # Sample n items
457        sampled = s.sample(n=2, random_state=42)
458        assert len(sampled) == 2, f"sample(n=2) should return 2 items, got {len(sampled)}"
459        f_print_info(f"  sample(n=2): {sampled.to_list()}")
460
461        # Sample fraction
462        sampled = s.sample(frac=0.4, random_state=42)
463        assert len(sampled) == 2, f"sample(frac=0.4) should return 2 items, got {len(sampled)}"
464        f_print_info(f"  sample(frac=0.4): {sampled.to_list()}")
465
466        f_print_success("Series sample: passed")
467        return True
tail (test_series.py:79)
69def test_series_tail():
70    """Test Series tail method"""
71    f_print_header("Test: Series tail")
72
73    try:
74        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])
75
76        # Test default n=5
77        tail = s.tail()
78        assert len(tail) == 5, f"Expected 5 elements, got {len(tail)}"
79        assert tail.to_list() == [6.0, 7.0, 8.0, 9.0, 10.0], "tail(5) values incorrect"
80
81        # Test custom n=3
82        tail = s.tail(3)
83        assert len(tail) == 3, f"Expected 3 elements, got {len(tail)}"
84        assert tail.to_list() == [8.0, 9.0, 10.0], "tail(3) values incorrect"
85
86        f_print_success("Series tail: passed")
87        return True
take (test_series.py:227)
217def test_series_take():
218    """Test Series take method"""
219    f_print_header("Test: Series take")
220
221    try:
222        s = pandasCore.Series([10.0, 20.0, 30.0, 40.0, 50.0])
223
224        # Take specific indices
225        taken = s.take([0, 2, 4])
226        assert len(taken) == 3, f"Expected 3 elements, got {len(taken)}"
227        assert taken.to_list() == [10.0, 30.0, 50.0], f"take values incorrect: {taken.to_list()}"
228
229        f_print_success("Series take: passed")
230        return True
231    except Exception as e:
232        f_print_error(f"Series take failed: {e}")
233        return False
where (test_series_phase2.py:585)
575def test_where():
576    """Test Series where method"""
577    f_print_header("Test: Series where")
578
579    try:
580        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
581
582        # Keep values where condition is True
583        cond = [True, False, True, False, True]
584        s_where = s.where(cond, other=0.0)
585        expected = [1.0, 0.0, 3.0, 0.0, 5.0]
586        assert s_where.to_list() == expected, f"Expected {expected}, got {s_where.to_list()}"
587
588        f_print_success("where: passed")
589        return True
590    except Exception as e:
591        f_print_error(f"where failed: {e}")
592        return False
xs (test_series_phase5.py:481)
471def test_xs():
472    """Test Series xs method"""
473    f_print_header("Test: Series xs")
474
475    try:
476        s = pandasCore.Series([1.0, 2.0, 3.0])
477
478        # xs returns value at label
479        value = s.xs("0")
480        assert value == 1.0, f"xs('0') should return 1.0, got {value}"
481        f_print_info(f"  xs('0'): {value}")
482
483        value = s.xs("2")
484        assert value == 3.0, f"xs('2') should return 3.0, got {value}"
485        f_print_info(f"  xs('2'): {value}")
486
487        f_print_success("Series xs: passed")
488        return True
489    except Exception as e:
drop (test_series_phase2.py:201)
191def test_drop():
192    """Test Series drop method"""
193    f_print_header("Test: Series drop")
194
195    try:
196        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
197
198        # Drop single label
199        s_dropped = s.drop("1")
200        assert len(s_dropped) == 4, f"Expected length 4, got {len(s_dropped)}"
201
202        # Drop multiple labels
203        s_dropped = s.drop(["0", "2"])
204        assert len(s_dropped) == 3, f"Expected length 3, got {len(s_dropped)}"
205
206        f_print_success("drop: passed")
207        return True
208    except Exception as e:
209        f_print_error(f"drop failed: {e}")
droplevel (test_series_phase2.py:263)
253def test_droplevel():
254    """Test Series droplevel method"""
255    f_print_header("Test: Series droplevel")
256
257    try:
258        # droplevel requires MultiIndex, but should raise for regular index
259        s = pandasCore.Series([1.0, 2.0, 3.0])
260
261        try:
262            s.droplevel(0)
263            # If no MultiIndex, it should raise
264        except RuntimeError as e:
265            if "MultiIndex" in str(e):
266                print(f"    Note: droplevel RuntimeError (expected for non-MultiIndex): {e}")
267            else:
268                raise
269
270        f_print_success("droplevel: passed (raises for non-MultiIndex)")
271        return True
272    except Exception as e:
pop (test_series.py:332)
322def test_series_pop():
323    """Test Series pop method"""
324    f_print_header("Test: Series pop")
325
326    try:
327        s = pandasCore.Series([10.0, 20.0, 30.0])
328
329        # Pop by label
330        val = s.pop("1")  # Pop the element at index "1" (value 20.0)
331        assert val == 20.0, f"Expected 20.0, got {val}"
332        assert len(s) == 2, f"After pop, expected 2 elements, got {len(s)}"
333
334        f_print_success("Series pop: passed")
335        return True
336    except Exception as e:
337        f_print_error(f"Series pop failed: {e}")
338        return False
reindex (test_series_phase2.py:78)
68def test_reindex():
69    """Test Series reindex method"""
70    f_print_header("Test: Series reindex")
71
72    try:
73        s = pandasCore.Series([1.0, 2.0, 3.0])
74
75        # Reindex with new labels
76        s_reindexed = s.reindex(["0", "1", "5"])
77        assert len(s_reindexed) == 3, f"Expected length 3, got {len(s_reindexed)}"
78
79        # Value at "5" should be NaN (not found in original)
80        vals = s_reindexed.to_list()
81        assert vals[0] == 1.0, f"Value at '0' should be 1.0, got {vals[0]}"
82        assert math.isnan(vals[2]), f"Value at '5' should be NaN, got {vals[2]}"
83
84        f_print_success("reindex: passed")
85        return True
86    except Exception as e:
rename (test_series_phase2.py:40)
30# =============================================================================
31
32def test_rename():
33    """Test Series rename method"""
34    f_print_header("Test: Series rename")
35
36    try:
37        s = pandasCore.Series([1.0, 2.0, 3.0], name="original")
38
39        # Rename by passing new name
40        s_renamed = s.rename("new_name")
41        assert s_renamed.name == "new_name", f"Expected name 'new_name', got {s_renamed.name}"
42        assert s.name == "original", "Original Series name should not change"
43
44        f_print_success("rename: passed")
45        return True
46    except Exception as e:
47        f_print_error(f"rename failed: {e}")
48        return False
rename_axis (test_series_phase2.py:59)
49def test_rename_axis():
50    """Test Series rename_axis method"""
51    f_print_header("Test: Series rename_axis")
52
53    try:
54        s = pandasCore.Series([1.0, 2.0, 3.0])
55
56        # Rename axis
57        s_renamed = s.rename_axis("my_index")
58        # Should not raise, returns Series
59        assert len(s_renamed) == 3, "Length should be preserved"
60
61        f_print_success("rename_axis: passed")
62        return True
63    except Exception as e:
64        f_print_error(f"rename_axis failed: {e}")
65        return False
reorder_levels (test_series_phase2.py:287)
277def test_reorder_levels():
278    """Test Series reorder_levels method"""
279    f_print_header("Test: Series reorder_levels")
280
281    try:
282        # reorder_levels requires MultiIndex
283        s = pandasCore.Series([1.0, 2.0, 3.0])
284
285        try:
286            s.reorder_levels([1, 0])
287        except RuntimeError as e:
288            if "MultiIndex" in str(e):
289                print(f"    Note: reorder_levels RuntimeError (expected for non-MultiIndex): {e}")
290            else:
291                raise
292
293        f_print_success("reorder_levels: passed (raises for non-MultiIndex)")
294        return True
295    except Exception as e:
296        f_print_error(f"reorder_levels failed: {e}")
replace (test_series_phase2.py:537)
527# =============================================================================
528
529def test_replace():
530    """Test Series replace method"""
531    f_print_header("Test: Series replace")
532
533    try:
534        s = pandasCore.Series([1.0, 2.0, 3.0, 2.0, 1.0])
535
536        # Replace single value
537        s_replaced = s.replace(2.0, 99.0)
538        expected = [1.0, 99.0, 3.0, 99.0, 1.0]
539        assert s_replaced.to_list() == expected, f"Expected {expected}, got {s_replaced.to_list()}"
540
541        # Replace with dict
542        s_replaced = s.replace({1.0: 10.0, 3.0: 30.0})
543        expected = [10.0, 2.0, 30.0, 2.0, 10.0]
544        assert s_replaced.to_list() == expected, f"Expected {expected}, got {s_replaced.to_list()}"
545
546        f_print_success("replace: passed")
547        return True
reset_index (test_series_phase2.py:160)
150def test_reset_index():
151    """Test Series reset_index method"""
152    f_print_header("Test: Series reset_index")
153
154    try:
155        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
156
157        # Reset index with drop=True returns Series
158        s_reset = s.reset_index(drop=True)
159        assert len(s_reset) == 3, f"Expected length 3, got {len(s_reset)}"
160
161        # Reset index with drop=False returns DataFrame
162        df = s.reset_index(drop=False)
163        assert df is not None, "reset_index(drop=False) should return DataFrame"
164
165        f_print_success("reset_index: passed")
166        return True
167    except Exception as e:
168        f_print_error(f"reset_index failed: {e}")
set_axis (test_series_phase2.py:182)
172def test_set_axis():
173    """Test Series set_axis method"""
174    f_print_header("Test: Series set_axis")
175
176    try:
177        s = pandasCore.Series([1.0, 2.0, 3.0])
178
179        # Set new axis labels
180        s_new = s.set_axis(["a", "b", "c"])
181        keys = s_new.keys()
182        assert keys == ["a", "b", "c"], f"Expected ['a', 'b', 'c'], got {keys}"
183
184        f_print_success("set_axis: passed")
185        return True
186    except Exception as e:
187        f_print_error(f"set_axis failed: {e}")
188        return False
swaplevel (test_series_phase2.py:310)
300def test_swaplevel():
301    """Test Series swaplevel method"""
302    f_print_header("Test: Series swaplevel")
303
304    try:
305        # swaplevel requires MultiIndex
306        s = pandasCore.Series([1.0, 2.0, 3.0])
307
308        try:
309            s.swaplevel()
310        except RuntimeError as e:
311            if "MultiIndex" in str(e):
312                print(f"    Note: swaplevel RuntimeError (expected for non-MultiIndex): {e}")
313            else:
314                raise
315
316        f_print_success("swaplevel: passed (raises for non-MultiIndex)")
317        return True
318    except Exception as e:
319        f_print_error(f"swaplevel failed: {e}")
backfill (test_series_phase2.py:477)
467        return False
468
469
470def test_backfill():
471    """Test Series backfill method (alias for bfill)"""
472    f_print_header("Test: Series backfill")
473
474    try:
475        s = pandasCore.Series([float('nan'), 2.0, float('nan')])
476
477        s_filled = s.backfill()
478        expected = [2.0, 2.0, float('nan')]  # Last NaN can't be backfilled
479        result = s_filled.to_list()
480        assert result[0] == 2.0 and result[1] == 2.0, f"Backfill incorrect: {result}"
481
482        f_print_success("backfill: passed")
483        return True
484    except Exception as e:
485        f_print_error(f"backfill failed: {e}")
486        return False
bfill (test_series_phase2.py:459)
449        return False
450
451
452def test_bfill():
453    """Test Series bfill method"""
454    f_print_header("Test: Series bfill")
455
456    try:
457        s = pandasCore.Series([float('nan'), 2.0, float('nan'), float('nan'), 5.0])
458
459        s_filled = s.bfill()
460        expected = [2.0, 2.0, 5.0, 5.0, 5.0]
461        assert s_filled.to_list() == expected, f"Expected {expected}, got {s_filled.to_list()}"
462
463        f_print_success("bfill: passed")
464        return True
465    except Exception as e:
466        f_print_error(f"bfill failed: {e}")
467        return False
dropna (test_series_phase2.py:405)
395        return False
396
397
398def test_dropna():
399    """Test Series dropna method"""
400    f_print_header("Test: Series dropna")
401
402    try:
403        s = pandasCore.Series([1.0, float('nan'), 3.0, float('nan'), 5.0])
404
405        s_clean = s.dropna()
406        assert len(s_clean) == 3, f"Expected 3 elements after dropna, got {len(s_clean)}"
407        assert s_clean.to_list() == [1.0, 3.0, 5.0], f"Values incorrect: {s_clean.to_list()}"
408
409        f_print_success("dropna: passed")
410        return True
411    except Exception as e:
412        f_print_error(f"dropna failed: {e}")
413        return False
ffill (test_series_phase2.py:441)
431        return False
432
433
434def test_ffill():
435    """Test Series ffill method"""
436    f_print_header("Test: Series ffill")
437
438    try:
439        s = pandasCore.Series([1.0, float('nan'), float('nan'), 4.0, float('nan')])
440
441        s_filled = s.ffill()
442        expected = [1.0, 1.0, 1.0, 4.0, 4.0]
443        assert s_filled.to_list() == expected, f"Expected {expected}, got {s_filled.to_list()}"
444
445        f_print_success("ffill: passed")
446        return True
447    except Exception as e:
448        f_print_error(f"ffill failed: {e}")
449        return False
fillna (test_series_phase2.py:424)
414def test_fillna():
415    """Test Series fillna method"""
416    f_print_header("Test: Series fillna")
417
418    try:
419        s = pandasCore.Series([1.0, float('nan'), 3.0, float('nan'), 5.0])
420
421        # Fill with scalar value
422        s_filled = s.fillna(0.0)
423        assert s_filled.to_list() == [1.0, 0.0, 3.0, 0.0, 5.0], f"Values incorrect: {s_filled.to_list()}"
424
425        f_print_success("fillna: passed")
426        return True
427    except Exception as e:
428        f_print_error(f"fillna failed: {e}")
429        return False
430
431
432def test_ffill():
interpolate (test_series_phase2.py:514)
504        return False
505
506
507def test_interpolate():
508    """Test Series interpolate method"""
509    f_print_header("Test: Series interpolate")
510
511    try:
512        s = pandasCore.Series([1.0, float('nan'), 3.0])
513
514        s_interp = s.interpolate(method="linear")
515        expected = [1.0, 2.0, 3.0]
516        assert s_interp.to_list() == expected, f"Expected {expected}, got {s_interp.to_list()}"
517
518        f_print_success("interpolate: passed")
519        return True
520    except Exception as e:
521        f_print_error(f"interpolate failed: {e}")
522        return False
isna (test_series_phase2.py:335)
325# NA Handling Tests (Methods 15-25)
326# =============================================================================
327
328def test_isna():
329    """Test Series isna method"""
330    f_print_header("Test: Series isna")
331
332    try:
333        s = pandasCore.Series([1.0, float('nan'), 3.0, float('nan')])
334
335        mask = s.isna()
336        assert len(mask) == 4, f"Expected 4 elements, got {len(mask)}"
337        assert mask == [False, True, False, True], f"Unexpected mask: {mask}"
338
339        f_print_success("isna: passed")
340        return True
341    except Exception as e:
342        f_print_error(f"isna failed: {e}")
343        return False
isnull (test_series_phase2.py:371)
361        return False
362
363
364def test_isnull():
365    """Test Series isnull method (alias for isna)"""
366    f_print_header("Test: Series isnull")
367
368    try:
369        s = pandasCore.Series([1.0, float('nan'), 3.0])
370
371        mask = s.isnull()
372        assert mask == [False, True, False], f"Unexpected mask: {mask}"
373
374        f_print_success("isnull: passed")
375        return True
376    except Exception as e:
377        f_print_error(f"isnull failed: {e}")
378        return False
379
380
381def test_notnull():
notna (test_series_phase2.py:353)
343        return False
344
345
346def test_notna():
347    """Test Series notna method"""
348    f_print_header("Test: Series notna")
349
350    try:
351        s = pandasCore.Series([1.0, float('nan'), 3.0, float('nan')])
352
353        mask = s.notna()
354        assert len(mask) == 4, f"Expected 4 elements, got {len(mask)}"
355        assert mask == [True, False, True, False], f"Unexpected mask: {mask}"
356
357        f_print_success("notna: passed")
358        return True
359    except Exception as e:
360        f_print_error(f"notna failed: {e}")
361        return False
notnull (test_series_phase2.py:388)
378        return False
379
380
381def test_notnull():
382    """Test Series notnull method (alias for notna)"""
383    f_print_header("Test: Series notnull")
384
385    try:
386        s = pandasCore.Series([1.0, float('nan'), 3.0])
387
388        mask = s.notnull()
389        assert mask == [True, False, True], f"Unexpected mask: {mask}"
390
391        f_print_success("notnull: passed")
392        return True
393    except Exception as e:
394        f_print_error(f"notnull failed: {e}")
395        return False
396
397
398def test_dropna():
pad (test_series_phase2.py:496)
486        return False
487
488
489def test_pad():
490    """Test Series pad method (alias for ffill)"""
491    f_print_header("Test: Series pad")
492
493    try:
494        s = pandasCore.Series([1.0, float('nan'), float('nan')])
495
496        s_filled = s.pad()
497        expected = [1.0, 1.0, 1.0]
498        assert s_filled.to_list() == expected, f"Expected {expected}, got {s_filled.to_list()}"
499
500        f_print_success("pad: passed")
501        return True
502    except Exception as e:
503        f_print_error(f"pad failed: {e}")
504        return False
count (test_series_phase3.py:218)
208        f_print_success(f"mode: {values} contains 2.0")
209        return True
210    f_print_error(f"mode: {values} does not contain 2.0")
211    return False
212
213
214def test_count():
215    """Test Series.count()"""
216    f_print_header("Test: count")
217    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
218    result = s.count()
219    if result == 5:
220        f_print_success(f"count: {result} == 5")
221        return True
222    f_print_error(f"count: {result} != 5")
223    return False
224
225
226def test_describe():
227    """Test Series.describe()"""
228    f_print_header("Test: describe")
cummax (test_series_phase3.py:329)
319        f_print_success(f"cummin: {values} == {expected}")
320        return True
321    f_print_error(f"cummin: {values} != {expected}")
322    return False
323
324
325def test_cummax():
326    """Test Series.cummax()"""
327    f_print_header("Test: cummax")
328    s = pandasCore.Series([1.0, 3.0, 2.0, 5.0, 4.0])
329    result = s.cummax()
330    values = result.values()
331    expected = [1.0, 3.0, 3.0, 5.0, 5.0]
332    if values == expected:
333        f_print_success(f"cummax: {values} == {expected}")
334        return True
335    f_print_error(f"cummax: {values} != {expected}")
336    return False
337
338
339def test_diff():
cummin (test_series_phase3.py:315)
305        f_print_success(f"cumprod: {values} == {expected}")
306        return True
307    f_print_error(f"cumprod: {values} != {expected}")
308    return False
309
310
311def test_cummin():
312    """Test Series.cummin()"""
313    f_print_header("Test: cummin")
314    s = pandasCore.Series([5.0, 3.0, 4.0, 1.0, 2.0])
315    result = s.cummin()
316    values = result.values()
317    expected = [5.0, 3.0, 3.0, 1.0, 1.0]
318    if values == expected:
319        f_print_success(f"cummin: {values} == {expected}")
320        return True
321    f_print_error(f"cummin: {values} != {expected}")
322    return False
323
324
325def test_cummax():
cumprod (test_series_phase3.py:301)
291        f_print_success(f"cumsum: {values} == {expected}")
292        return True
293    f_print_error(f"cumsum: {values} != {expected}")
294    return False
295
296
297def test_cumprod():
298    """Test Series.cumprod()"""
299    f_print_header("Test: cumprod")
300    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
301    result = s.cumprod()
302    values = result.values()
303    expected = [1.0, 2.0, 6.0, 24.0, 120.0]
304    if values == expected:
305        f_print_success(f"cumprod: {values} == {expected}")
306        return True
307    f_print_error(f"cumprod: {values} != {expected}")
308    return False
309
310
311def test_cummin():
cumsum (test_series_phase3.py:287)
277        f_print_success(f"argmin: {result} == 1")
278        return True
279    f_print_error(f"argmin: {result} != 1")
280    return False
281
282
283def test_cumsum():
284    """Test Series.cumsum()"""
285    f_print_header("Test: cumsum")
286    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
287    result = s.cumsum()
288    values = result.values()
289    expected = [1.0, 3.0, 6.0, 10.0, 15.0]
290    if values == expected:
291        f_print_success(f"cumsum: {values} == {expected}")
292        return True
293    f_print_error(f"cumsum: {values} != {expected}")
294    return False
295
296
297def test_cumprod():
describe (test_series_phase3.py:231)
221        return True
222    f_print_error(f"count: {result} != 5")
223    return False
224
225
226def test_describe():
227    """Test Series.describe()"""
228    f_print_header("Test: describe")
229    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
230    try:
231        result = s.describe()
232        f_print_success(f"describe: returned DataFrame")
233        return True
234    except Exception as e:
235        f_print_error(f"describe: {e}")
236        return False
237
238
239def test_idxmax():
240    """Test Series.idxmax()"""
241    f_print_header("Test: idxmax")
kurt (test_series_phase3.py:168)
158        f_print_success(f"skew: {result} ~= 0.0 (symmetric)")
159        return True
160    f_print_error(f"skew: {result} != ~0.0")
161    return False
162
163
164def test_kurt():
165    """Test Series.kurt()"""
166    f_print_header("Test: kurt")
167    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
168    result = s.kurt()
169    # Result should be a valid float
170    if result is not None:
171        f_print_success(f"kurt: {result} (valid result)")
172        return True
173    f_print_error("kurt: returned None")
174    return False
175
176
177def test_kurtosis():
178    """Test Series.kurtosis() - alias for kurt"""
kurtosis (test_series_phase3.py:181)
171        f_print_success(f"kurt: {result} (valid result)")
172        return True
173    f_print_error("kurt: returned None")
174    return False
175
176
177def test_kurtosis():
178    """Test Series.kurtosis() - alias for kurt"""
179    f_print_header("Test: kurtosis")
180    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
181    result = s.kurtosis()
182    if result is not None:
183        f_print_success(f"kurtosis: {result} (valid result)")
184        return True
185    f_print_error("kurtosis: returned None")
186    return False
187
188
189def test_quantile():
190    """Test Series.quantile()"""
191    f_print_header("Test: quantile")
max (test_series_phase3.py:105)
 95        f_print_success(f"min: {result} == 1.0")
 96        return True
 97    f_print_error(f"min: {result} != 1.0")
 98    return False
 99
100
101def test_max():
102    """Test Series.max()"""
103    f_print_header("Test: max")
104    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0])
105    result = s.max()
106    if result == 5.0:
107        f_print_success(f"max: {result} == 5.0")
108        return True
109    f_print_error(f"max: {result} != 5.0")
110    return False
111
112
113def test_std():
114    """Test Series.std()"""
115    f_print_header("Test: std")
mean (test_series_phase3.py:69)
59        f_print_success(f"product: {result} == 120.0")
60        return True
61    f_print_error(f"product: {result} != 120.0")
62    return False
63
64
65def test_mean():
66    """Test Series.mean()"""
67    f_print_header("Test: mean")
68    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
69    result = s.mean()
70    if result == 3.0:
71        f_print_success(f"mean: {result} == 3.0")
72        return True
73    f_print_error(f"mean: {result} != 3.0")
74    return False
75
76
77def test_median():
78    """Test Series.median()"""
79    f_print_header("Test: median")
median (test_series_phase3.py:81)
71        f_print_success(f"mean: {result} == 3.0")
72        return True
73    f_print_error(f"mean: {result} != 3.0")
74    return False
75
76
77def test_median():
78    """Test Series.median()"""
79    f_print_header("Test: median")
80    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
81    result = s.median()
82    if result == 3.0:
83        f_print_success(f"median: {result} == 3.0")
84        return True
85    f_print_error(f"median: {result} != 3.0")
86    return False
87
88
89def test_min():
90    """Test Series.min()"""
91    f_print_header("Test: min")
min (test_series_phase3.py:93)
 83        f_print_success(f"median: {result} == 3.0")
 84        return True
 85    f_print_error(f"median: {result} != 3.0")
 86    return False
 87
 88
 89def test_min():
 90    """Test Series.min()"""
 91    f_print_header("Test: min")
 92    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0])
 93    result = s.min()
 94    if result == 1.0:
 95        f_print_success(f"min: {result} == 1.0")
 96        return True
 97    f_print_error(f"min: {result} != 1.0")
 98    return False
 99
100
101def test_max():
102    """Test Series.max()"""
103    f_print_header("Test: max")
mode (test_series_phase3.py:205)
195        f_print_success(f"quantile(0.5): {result} == 3.0")
196        return True
197    f_print_error(f"quantile(0.5): {result} != 3.0")
198    return False
199
200
201def test_mode():
202    """Test Series.mode()"""
203    f_print_header("Test: mode")
204    s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 2.0])
205    result = s.mode()
206    values = result.values()
207    if 2.0 in values:
208        f_print_success(f"mode: {values} contains 2.0")
209        return True
210    f_print_error(f"mode: {values} does not contain 2.0")
211    return False
212
213
214def test_count():
215    """Test Series.count()"""
nunique (test_series_phase2.py:718)
708        return False
709
710
711def test_nunique():
712    """Test Series nunique method"""
713    f_print_header("Test: Series nunique")
714
715    try:
716        s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 1.0, 3.0])
717
718        count = s.nunique()
719        assert count == 3, f"Expected 3 unique values, got {count}"
720
721        # Test with NaN
722        s_nan = pandasCore.Series([1.0, float('nan'), 2.0, float('nan')])
723        count_dropna = s_nan.nunique(dropna=True)
724        assert count_dropna == 2, f"Expected 2 unique (dropna=True), got {count_dropna}"
725
726        f_print_success("nunique: passed")
727        return True
728    except Exception as e:
prod (test_series_phase3.py:45)
35        f_print_success(f"sum: {result} == 15.0")
36        return True
37    f_print_error(f"sum: {result} != 15.0")
38    return False
39
40
41def test_prod():
42    """Test Series.prod()"""
43    f_print_header("Test: prod")
44    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
45    result = s.prod()
46    if result == 120.0:
47        f_print_success(f"prod: {result} == 120.0")
48        return True
49    f_print_error(f"prod: {result} != 120.0")
50    return False
51
52
53def test_product():
54    """Test Series.product() - alias for prod"""
55    f_print_header("Test: product")
quantile (test_series_phase3.py:193)
183        f_print_success(f"kurtosis: {result} (valid result)")
184        return True
185    f_print_error("kurtosis: returned None")
186    return False
187
188
189def test_quantile():
190    """Test Series.quantile()"""
191    f_print_header("Test: quantile")
192    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
193    result = s.quantile(0.5)
194    if result == 3.0:
195        f_print_success(f"quantile(0.5): {result} == 3.0")
196        return True
197    f_print_error(f"quantile(0.5): {result} != 3.0")
198    return False
199
200
201def test_mode():
202    """Test Series.mode()"""
203    f_print_header("Test: mode")
sem (test_series_phase3.py:142)
132        f_print_success(f"var: {result} == 2.5")
133        return True
134    f_print_error(f"var: {result} != 2.5")
135    return False
136
137
138def test_sem():
139    """Test Series.sem()"""
140    f_print_header("Test: sem")
141    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
142    result = s.sem()
143    expected = math.sqrt(2.5) / math.sqrt(5)
144    if abs(result - expected) < 1e-10:
145        f_print_success(f"sem: {result} ~= {expected}")
146        return True
147    f_print_error(f"sem: {result} != {expected}")
148    return False
149
150
151def test_skew():
152    """Test Series.skew()"""
skew (test_series_phase3.py:155)
145        f_print_success(f"sem: {result} ~= {expected}")
146        return True
147    f_print_error(f"sem: {result} != {expected}")
148    return False
149
150
151def test_skew():
152    """Test Series.skew()"""
153    f_print_header("Test: skew")
154    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
155    result = s.skew()
156    # Symmetric distribution should have skew close to 0
157    if abs(result) < 1e-10:
158        f_print_success(f"skew: {result} ~= 0.0 (symmetric)")
159        return True
160    f_print_error(f"skew: {result} != ~0.0")
161    return False
162
163
164def test_kurt():
165    """Test Series.kurt()"""
std (test_series_phase3.py:117)
107        f_print_success(f"max: {result} == 5.0")
108        return True
109    f_print_error(f"max: {result} != 5.0")
110    return False
111
112
113def test_std():
114    """Test Series.std()"""
115    f_print_header("Test: std")
116    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
117    result = s.std()
118    expected = math.sqrt(2.5)  # Sample std with ddof=1
119    if abs(result - expected) < 1e-10:
120        f_print_success(f"std: {result} ~= {expected}")
121        return True
122    f_print_error(f"std: {result} != {expected}")
123    return False
124
125
126def test_var():
127    """Test Series.var()"""
sum (test_series_phase3.py:33)
23# Direct imports
24import pandasCore
25import pandas as pd
26
27
28def test_sum():
29    """Test Series.sum()"""
30    f_print_header("Test: sum")
31    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
32    result = s.sum()
33    if result == 15.0:
34        f_print_success(f"sum: {result} == 15.0")
35        return True
36    f_print_error(f"sum: {result} != 15.0")
37    return False
38
39
40def test_prod():
41    """Test Series.prod()"""
42    f_print_header("Test: prod")
value_counts (test_series_phase3.py:447)
437        f_print_success(f"nsmallest(3): {values} contains 1.0, 1.0, 2.0")
438        return True
439    f_print_error(f"nsmallest(3): {values} incorrect")
440    return False
441
442
443def test_value_counts():
444    """Test Series.value_counts()"""
445    f_print_header("Test: value_counts")
446    s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0])
447    result = s.value_counts()
448    f_print_success(f"value_counts: returned IntSeries")
449    return True
450
451
452def test_agg():
453    """Test Series.agg()"""
454    f_print_header("Test: agg")
455    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
456    result = s.agg("sum")
457    if result == 15.0:
var (test_series_phase3.py:130)
120        f_print_success(f"std: {result} ~= {expected}")
121        return True
122    f_print_error(f"std: {result} != {expected}")
123    return False
124
125
126def test_var():
127    """Test Series.var()"""
128    f_print_header("Test: var")
129    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
130    result = s.var()
131    if result == 2.5:  # Sample variance with ddof=1
132        f_print_success(f"var: {result} == 2.5")
133        return True
134    f_print_error(f"var: {result} != 2.5")
135    return False
136
137
138def test_sem():
139    """Test Series.sem()"""
140    f_print_header("Test: sem")
agg (test_series_phase3.py:456)
446    s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0])
447    result = s.value_counts()
448    f_print_success(f"value_counts: returned IntSeries")
449    return True
450
451
452def test_agg():
453    """Test Series.agg()"""
454    f_print_header("Test: agg")
455    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
456    result = s.agg("sum")
457    if result == 15.0:
458        f_print_success(f"agg('sum'): {result} == 15.0")
459        return True
460    f_print_error(f"agg('sum'): {result} != 15.0")
461    return False
462
463
464def test_aggregate():
465    """Test Series.aggregate() - alias for agg"""
466    f_print_header("Test: aggregate")
aggregate (test_series_phase3.py:468)
458        f_print_success(f"agg('sum'): {result} == 15.0")
459        return True
460    f_print_error(f"agg('sum'): {result} != 15.0")
461    return False
462
463
464def test_aggregate():
465    """Test Series.aggregate() - alias for agg"""
466    f_print_header("Test: aggregate")
467    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
468    result = s.aggregate("mean")
469    if result == 3.0:
470        f_print_success(f"aggregate('mean'): {result} == 3.0")
471        return True
472    f_print_error(f"aggregate('mean'): {result} != 3.0")
473    return False
474
475
476def test_apply():
477    """Test Series.apply()"""
478    f_print_header("Test: apply")
apply (test_series_phase3.py:480)
470        f_print_success(f"aggregate('mean'): {result} == 3.0")
471        return True
472    f_print_error(f"aggregate('mean'): {result} != 3.0")
473    return False
474
475
476def test_apply():
477    """Test Series.apply()"""
478    f_print_header("Test: apply")
479    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
480    result = s.apply(lambda x: x * 2)
481    values = result.values()
482    expected = [2.0, 4.0, 6.0, 8.0, 10.0]
483    if values == expected:
484        f_print_success(f"apply(x*2): {values} == {expected}")
485        return True
486    f_print_error(f"apply(x*2): {values} != {expected}")
487    return False
488
489
490def test_map():
ewm (test_series_phase5.py:361)
351def test_ewm_placeholder():
352    """Test Series ewm functionality"""
353    f_print_header("Test: Series ewm")
354
355    try:
356        s = pandasCore.Series([1.0, 2.0, 3.0])
357
358        # ewm should return a SeriesEWM object with working mean()
359        ewm_obj = s.ewm(span=2)
360        result = ewm_obj.mean()
361        f_print_info(f"  ewm(span=2).mean() = {result.tolist()}")
362
363        f_print_success("Series ewm: passed")
364        return True
365    except Exception as e:
366        f_print_error(f"Series ewm failed: {e}")
367        return False
expanding (test_series_phase5.py:342)
332def test_expanding_placeholder():
333    """Test Series expanding functionality"""
334    f_print_header("Test: Series expanding")
335
336    try:
337        s = pandasCore.Series([1.0, 2.0, 3.0])
338
339        # expanding should return a SeriesExpanding object with working mean()
340        exp_obj = s.expanding()
341        result = exp_obj.mean()
342        f_print_info(f"  expanding().mean() = {result.tolist()}")
343
344        f_print_success("Series expanding: passed")
345        return True
346    except Exception as e:
347        f_print_error(f"Series expanding failed: {e}")
348        return False
groupby (test_series_phase5.py:296)
286# Grouping & Windowing Methods Tests
287# ============================================================================
288
289def test_groupby_placeholder():
290    """Test Series groupby"""
291    f_print_header("Test: Series groupby")
292
293    try:
294        # Test groupby with level=0 (group by index)
295        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0], index=['a', 'a', 'b', 'b'])
296        gb = s.groupby(level=0)
297        result = gb.sum()
298        assert result.tolist() == [3.0, 7.0], f"Expected [3.0, 7.0], got {result.tolist()}"
299        f_print_info(f"  groupby(level=0).sum() = {result.tolist()}")
300
301        # Test groupby with by= list
302        s2 = pandasCore.Series([10.0, 20.0, 30.0])
303        gb2 = s2.groupby(by=['x', 'x', 'y'])
304        result2 = gb2.sum()
305        assert result2.tolist() == [30.0, 30.0], f"Expected [30.0, 30.0], got {result2.tolist()}"
306        f_print_info(f"  groupby(by=list).sum() = {result2.tolist()}")
map (test_series_phase3.py:495)
485        return True
486    f_print_error(f"apply(x*2): {values} != {expected}")
487    return False
488
489
490def test_map():
491    """Test Series.map()"""
492    f_print_header("Test: map")
493    s = pandasCore.Series([1.0, 2.0, 3.0])
494    mapping = {1.0: 10.0, 2.0: 20.0, 3.0: 30.0}
495    result = s.map(mapping)
496    values = result.values()
497    expected = [10.0, 20.0, 30.0]
498    if values == expected:
499        f_print_success(f"map(dict): {values} == {expected}")
500        return True
501    f_print_error(f"map(dict): {values} != {expected}")
502    return False
503
504
505def test_transform():
pipe (test_series_phase3.py:527)
517def test_pipe():
518    """Test Series.pipe()"""
519    f_print_header("Test: pipe")
520    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
521
522    def double_sum(series):
523        return series.sum() * 2
524
525    result = s.pipe(double_sum)
526    if result == 30.0:
527        f_print_success(f"pipe(double_sum): {result} == 30.0")
528        return True
529    f_print_error(f"pipe(double_sum): {result} != 30.0")
530    return False
531
532
533def test_all():
534    """Test Series.all()"""
535    f_print_header("Test: all")
resample (test_series_phase5.py:381)
371def test_resample_placeholder():
372    """Test Series resample works"""
373    f_print_header("Test: Series resample (placeholder)")
374
375    try:
376        dates = pandasCore.date_range('2023-01-01', periods=3, freq='D')
377        s = pandasCore.Series([1.0, 2.0, 3.0], index=dates)
378
379        # resample should return a SeriesResampler object
380        resampler = s.resample("D")
381        result = resampler.sum()
382        f_print_info(f"  resample('D').sum() returned {len(result)} values")
383
384        f_print_success("Series resample placeholder: passed")
385        return True
386    except Exception as e:
387        f_print_error(f"Series resample placeholder failed: {e}")
388        return False
rolling (test_series_phase5.py:323)
313def test_rolling_placeholder():
314    """Test Series rolling works"""
315    f_print_header("Test: Series rolling (placeholder)")
316
317    try:
318        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
319
320        # rolling should return a Rolling object
321        r = s.rolling(window=2)
322        result = r.mean()
323        f_print_info(f"  rolling(2).mean() returned {len(result)} values")
324
325        f_print_success("Series rolling placeholder: passed")
326        return True
327    except Exception as e:
328        f_print_error(f"Series rolling placeholder failed: {e}")
329        return False
transform (test_series_phase3.py:509)
499        f_print_success(f"map(dict): {values} == {expected}")
500        return True
501    f_print_error(f"map(dict): {values} != {expected}")
502    return False
503
504
505def test_transform():
506    """Test Series.transform()"""
507    f_print_header("Test: transform")
508    s = pandasCore.Series([1.0, 4.0, 9.0, 16.0])
509    result = s.transform("sqrt")
510    values = result.values()
511    expected = [1.0, 2.0, 3.0, 4.0]
512    if values == expected:
513        f_print_success(f"transform('sqrt'): {values} == {expected}")
514        return True
515    f_print_error(f"transform('sqrt'): {values} != {expected}")
516    return False
517
518
519def test_pipe():
add (test_series_phase4.py:36)
26import pandas as pd
27
28
29# ==================== Arithmetic Tests ====================
30
31def test_add_scalar():
32    """Test Series add with scalar"""
33    f_print_header("Test: Series add (scalar)")
34    try:
35        s = pandasCore.Series([1.0, 2.0, 3.0])
36        result = s.add(10.0)
37        expected = [11.0, 12.0, 13.0]
38        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
39        f_print_success("add (scalar): passed")
40        return True
41    except Exception as e:
42        f_print_error(f"add (scalar) failed: {e}")
43        return False
44
45
46def test_add_series():
div (test_series_phase4.py:97)
 87    except Exception as e:
 88        f_print_error(f"mul (scalar) failed: {e}")
 89        return False
 90
 91
 92def test_div_scalar():
 93    """Test Series div with scalar"""
 94    f_print_header("Test: Series div (scalar)")
 95    try:
 96        s = pandasCore.Series([10.0, 20.0, 30.0])
 97        result = s.div(2.0)
 98        expected = [5.0, 10.0, 15.0]
 99        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
100        f_print_success("div (scalar): passed")
101        return True
102    except Exception as e:
103        f_print_error(f"div (scalar) failed: {e}")
104        return False
105
106
107def test_truediv():
floordiv (test_series_phase4.py:127)
117    except Exception as e:
118        f_print_error(f"truediv failed: {e}")
119        return False
120
121
122def test_floordiv():
123    """Test Series floordiv"""
124    f_print_header("Test: Series floordiv")
125    try:
126        s = pandasCore.Series([10.0, 21.0, 35.0])
127        result = s.floordiv(4.0)
128        expected = [2.0, 5.0, 8.0]
129        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
130        f_print_success("floordiv: passed")
131        return True
132    except Exception as e:
133        f_print_error(f"floordiv failed: {e}")
134        return False
135
136
137def test_mod():
mod (test_series_phase4.py:142)
132    except Exception as e:
133        f_print_error(f"floordiv failed: {e}")
134        return False
135
136
137def test_mod():
138    """Test Series mod"""
139    f_print_header("Test: Series mod")
140    try:
141        s = pandasCore.Series([10.0, 21.0, 35.0])
142        result = s.mod(4.0)
143        expected = [2.0, 1.0, 3.0]
144        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
145        f_print_success("mod: passed")
146        return True
147    except Exception as e:
148        f_print_error(f"mod failed: {e}")
149        return False
150
151
152def test_pow():
mul (test_series_phase4.py:82)
72    except Exception as e:
73        f_print_error(f"sub (scalar) failed: {e}")
74        return False
75
76
77def test_mul_scalar():
78    """Test Series mul with scalar"""
79    f_print_header("Test: Series mul (scalar)")
80    try:
81        s = pandasCore.Series([1.0, 2.0, 3.0])
82        result = s.mul(2.0)
83        expected = [2.0, 4.0, 6.0]
84        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
85        f_print_success("mul (scalar): passed")
86        return True
87    except Exception as e:
88        f_print_error(f"mul (scalar) failed: {e}")
89        return False
90
91
92def test_div_scalar():
pow (test_series_phase4.py:157)
147    except Exception as e:
148        f_print_error(f"mod failed: {e}")
149        return False
150
151
152def test_pow():
153    """Test Series pow"""
154    f_print_header("Test: Series pow")
155    try:
156        s = pandasCore.Series([2.0, 3.0, 4.0])
157        result = s.pow(2.0)
158        expected = [4.0, 9.0, 16.0]
159        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
160        f_print_success("pow: passed")
161        return True
162    except Exception as e:
163        f_print_error(f"pow failed: {e}")
164        return False
165
166
167# ==================== Reverse Arithmetic Tests ====================
radd (test_series_phase4.py:174)
164        return False
165
166
167# ==================== Reverse Arithmetic Tests ====================
168
169def test_radd():
170    """Test Series radd"""
171    f_print_header("Test: Series radd")
172    try:
173        s = pandasCore.Series([1.0, 2.0, 3.0])
174        result = s.radd(10.0)
175        expected = [11.0, 12.0, 13.0]
176        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
177        f_print_success("radd: passed")
178        return True
179    except Exception as e:
180        f_print_error(f"radd failed: {e}")
181        return False
182
183
184def test_rsub():
rdiv (test_series_phase4.py:219)
209    except Exception as e:
210        f_print_error(f"rmul failed: {e}")
211        return False
212
213
214def test_rdiv():
215    """Test Series rdiv"""
216    f_print_header("Test: Series rdiv")
217    try:
218        s = pandasCore.Series([1.0, 2.0, 4.0])
219        result = s.rdiv(8.0)  # 8 / [1, 2, 4] = [8, 4, 2]
220        expected = [8.0, 4.0, 2.0]
221        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
222        f_print_success("rdiv: passed")
223        return True
224    except Exception as e:
225        f_print_error(f"rdiv failed: {e}")
226        return False
227
228
229def test_rfloordiv():
rfloordiv (test_series_phase4.py:234)
224    except Exception as e:
225        f_print_error(f"rdiv failed: {e}")
226        return False
227
228
229def test_rfloordiv():
230    """Test Series rfloordiv"""
231    f_print_header("Test: Series rfloordiv")
232    try:
233        s = pandasCore.Series([3.0, 4.0, 5.0])
234        result = s.rfloordiv(10.0)  # 10 // [3, 4, 5] = [3, 2, 2]
235        expected = [3.0, 2.0, 2.0]
236        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
237        f_print_success("rfloordiv: passed")
238        return True
239    except Exception as e:
240        f_print_error(f"rfloordiv failed: {e}")
241        return False
242
243
244def test_rmod():
rmod (test_series_phase4.py:249)
239    except Exception as e:
240        f_print_error(f"rfloordiv failed: {e}")
241        return False
242
243
244def test_rmod():
245    """Test Series rmod"""
246    f_print_header("Test: Series rmod")
247    try:
248        s = pandasCore.Series([3.0, 4.0, 5.0])
249        result = s.rmod(10.0)  # 10 % [3, 4, 5] = [1, 2, 0]
250        expected = [1.0, 2.0, 0.0]
251        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
252        f_print_success("rmod: passed")
253        return True
254    except Exception as e:
255        f_print_error(f"rmod failed: {e}")
256        return False
257
258
259def test_rpow():
rmul (test_series_phase4.py:204)
194    except Exception as e:
195        f_print_error(f"rsub failed: {e}")
196        return False
197
198
199def test_rmul():
200    """Test Series rmul"""
201    f_print_header("Test: Series rmul")
202    try:
203        s = pandasCore.Series([1.0, 2.0, 3.0])
204        result = s.rmul(5.0)
205        expected = [5.0, 10.0, 15.0]
206        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
207        f_print_success("rmul: passed")
208        return True
209    except Exception as e:
210        f_print_error(f"rmul failed: {e}")
211        return False
212
213
214def test_rdiv():
rpow (test_series_phase4.py:264)
254    except Exception as e:
255        f_print_error(f"rmod failed: {e}")
256        return False
257
258
259def test_rpow():
260    """Test Series rpow"""
261    f_print_header("Test: Series rpow")
262    try:
263        s = pandasCore.Series([1.0, 2.0, 3.0])
264        result = s.rpow(2.0)  # 2 ** [1, 2, 3] = [2, 4, 8]
265        expected = [2.0, 4.0, 8.0]
266        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
267        f_print_success("rpow: passed")
268        return True
269    except Exception as e:
270        f_print_error(f"rpow failed: {e}")
271        return False
272
273
274def test_divmod():
rsub (test_series_phase4.py:189)
179    except Exception as e:
180        f_print_error(f"radd failed: {e}")
181        return False
182
183
184def test_rsub():
185    """Test Series rsub"""
186    f_print_header("Test: Series rsub")
187    try:
188        s = pandasCore.Series([1.0, 2.0, 3.0])
189        result = s.rsub(10.0)  # 10 - [1, 2, 3] = [9, 8, 7]
190        expected = [9.0, 8.0, 7.0]
191        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
192        f_print_success("rsub: passed")
193        return True
194    except Exception as e:
195        f_print_error(f"rsub failed: {e}")
196        return False
197
198
199def test_rmul():
sub (test_series_phase4.py:67)
57    except Exception as e:
58        f_print_error(f"add (series) failed: {e}")
59        return False
60
61
62def test_sub_scalar():
63    """Test Series sub with scalar"""
64    f_print_header("Test: Series sub (scalar)")
65    try:
66        s = pandasCore.Series([10.0, 20.0, 30.0])
67        result = s.sub(5.0)
68        expected = [5.0, 15.0, 25.0]
69        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
70        f_print_success("sub (scalar): passed")
71        return True
72    except Exception as e:
73        f_print_error(f"sub (scalar) failed: {e}")
74        return False
75
76
77def test_mul_scalar():
truediv (test_series_phase4.py:112)
102    except Exception as e:
103        f_print_error(f"div (scalar) failed: {e}")
104        return False
105
106
107def test_truediv():
108    """Test Series truediv"""
109    f_print_header("Test: Series truediv")
110    try:
111        s = pandasCore.Series([10.0, 20.0, 30.0])
112        result = s.truediv(4.0)
113        expected = [2.5, 5.0, 7.5]
114        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
115        f_print_success("truediv: passed")
116        return True
117    except Exception as e:
118        f_print_error(f"truediv failed: {e}")
119        return False
120
121
122def test_floordiv():
eq (test_series_phase4.py:408)
398    except Exception as e:
399        f_print_error(f"clip failed: {e}")
400        return False
401
402
403def test_eq():
404    """Test Series eq"""
405    f_print_header("Test: Series eq")
406    try:
407        s = pandasCore.Series([1.0, 2.0, 3.0])
408        result = s.eq(2.0)
409        expected = [False, True, False]
410        assert result == expected, f"Expected {expected}, got {result}"
411        f_print_success("eq: passed")
412        return True
413    except Exception as e:
414        f_print_error(f"eq failed: {e}")
415        return False
416
417
418def test_ne():
ge (test_series_phase4.py:483)
473    except Exception as e:
474        f_print_error(f"gt failed: {e}")
475        return False
476
477
478def test_ge():
479    """Test Series ge"""
480    f_print_header("Test: Series ge")
481    try:
482        s = pandasCore.Series([1.0, 2.0, 3.0])
483        result = s.ge(2.0)
484        expected = [False, True, True]
485        assert result == expected, f"Expected {expected}, got {result}"
486        f_print_success("ge: passed")
487        return True
488    except Exception as e:
489        f_print_error(f"ge failed: {e}")
490        return False
491
492
493def test_combine_first():
gt (test_series_phase4.py:468)
458    except Exception as e:
459        f_print_error(f"le failed: {e}")
460        return False
461
462
463def test_gt():
464    """Test Series gt"""
465    f_print_header("Test: Series gt")
466    try:
467        s = pandasCore.Series([1.0, 2.0, 3.0])
468        result = s.gt(2.0)
469        expected = [False, False, True]
470        assert result == expected, f"Expected {expected}, got {result}"
471        f_print_success("gt: passed")
472        return True
473    except Exception as e:
474        f_print_error(f"gt failed: {e}")
475        return False
476
477
478def test_ge():
le (test_series_phase4.py:453)
443    except Exception as e:
444        f_print_error(f"lt failed: {e}")
445        return False
446
447
448def test_le():
449    """Test Series le"""
450    f_print_header("Test: Series le")
451    try:
452        s = pandasCore.Series([1.0, 2.0, 3.0])
453        result = s.le(2.0)
454        expected = [True, True, False]
455        assert result == expected, f"Expected {expected}, got {result}"
456        f_print_success("le: passed")
457        return True
458    except Exception as e:
459        f_print_error(f"le failed: {e}")
460        return False
461
462
463def test_gt():
lt (test_series_phase4.py:438)
428    except Exception as e:
429        f_print_error(f"ne failed: {e}")
430        return False
431
432
433def test_lt():
434    """Test Series lt"""
435    f_print_header("Test: Series lt")
436    try:
437        s = pandasCore.Series([1.0, 2.0, 3.0])
438        result = s.lt(2.0)
439        expected = [True, False, False]
440        assert result == expected, f"Expected {expected}, got {result}"
441        f_print_success("lt: passed")
442        return True
443    except Exception as e:
444        f_print_error(f"lt failed: {e}")
445        return False
446
447
448def test_le():
ne (test_series_phase4.py:423)
413    except Exception as e:
414        f_print_error(f"eq failed: {e}")
415        return False
416
417
418def test_ne():
419    """Test Series ne"""
420    f_print_header("Test: Series ne")
421    try:
422        s = pandasCore.Series([1.0, 2.0, 3.0])
423        result = s.ne(2.0)
424        expected = [True, False, True]
425        assert result == expected, f"Expected {expected}, got {result}"
426        f_print_success("ne: passed")
427        return True
428    except Exception as e:
429        f_print_error(f"ne failed: {e}")
430        return False
431
432
433def test_lt():
argsort (test_series_phase5.py:89)
79def test_argsort():
80    """Test Series argsort method"""
81    f_print_header("Test: Series argsort")
82
83    try:
84        s = pandasCore.Series([3.0, 1.0, 2.0], name="values")
85
86        # argsort should return indices that would sort the array
87        indices = s.argsort()
88        # Original: [3, 1, 2] -> sorted: [1, 2, 3] -> indices: [1, 2, 0]
89        assert indices == [1, 2, 0], f"argsort failed: {indices}"
90        f_print_info(f"  argsort([3,1,2]) = {indices}")
91
92        f_print_success("Series argsort: passed")
93        return True
94    except Exception as e:
95        f_print_error(f"Series argsort failed: {e}")
96        return False
rank (test_series_phase3.py:410)
400        f_print_success(f"autocorr: {result}")
401        return True
402    f_print_error("autocorr: returned None")
403    return False
404
405
406def test_rank():
407    """Test Series.rank()"""
408    f_print_header("Test: rank")
409    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0])
410    result = s.rank()
411    values = result.values()
412    # With method='average': 1.0 gets rank 1.5, 3.0 gets rank 3, 4.0 gets rank 4, 5.0 gets rank 5
413    f_print_success(f"rank: {values}")
414    return True
415
416
417def test_nlargest():
418    """Test Series.nlargest()"""
419    f_print_header("Test: nlargest")
420    s = pandasCore.Series([3.0, 1.0, 4.0, 1.0, 5.0, 9.0, 2.0, 6.0])
searchsorted (test_series_phase3.py:587)
577        f_print_success(f"last_valid_index: {result} == 2")
578        return True
579    f_print_error(f"last_valid_index: {result} != 2")
580    return False
581
582
583def test_searchsorted():
584    """Test Series.searchsorted()"""
585    f_print_header("Test: searchsorted")
586    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
587    result = s.searchsorted(3.5)
588    if result == 3:  # 3.5 would be inserted at position 3
589        f_print_success(f"searchsorted(3.5): {result} == 3")
590        return True
591    f_print_error(f"searchsorted(3.5): {result} != 3")
592    return False
593
594
595def f_main():
596    """Main test function"""
597    # Run tests
sort_index (test_series_phase5.py:67)
57def test_sort_index():
58    """Test Series sort_index method"""
59    f_print_header("Test: Series sort_index")
60
61    try:
62        # Create series with custom index (in reverse order)
63        s = pandasCore.Series([3.0, 2.0, 1.0], name="values")
64
65        # Test ascending sort
66        sorted_s = s.sort_index()
67        f_print_info(f"  Sort index result: {sorted_s.to_list()}")
68
69        # Test descending sort
70        sorted_s = s.sort_index(ascending=False)
71        f_print_info(f"  Sort index descending: {sorted_s.to_list()}")
72
73        f_print_success("Series sort_index: passed")
74        return True
75    except Exception as e:
76        f_print_error(f"Series sort_index failed: {e}")
sort_values (test_series_phase5.py:40)
30# ============================================================================
31
32def test_sort_values():
33    """Test Series sort_values method"""
34    f_print_header("Test: Series sort_values")
35
36    try:
37        s = pandasCore.Series([3.0, 1.0, 2.0, 5.0, 4.0], name="values")
38
39        # Test ascending sort (default)
40        sorted_s = s.sort_values()
41        values = sorted_s.to_list()
42        assert values == [1.0, 2.0, 3.0, 4.0, 5.0], f"Ascending sort failed: {values}"
43        f_print_info("  Ascending sort: OK")
44
45        # Test descending sort
46        sorted_s = s.sort_values(ascending=False)
47        values = sorted_s.to_list()
48        assert values == [5.0, 4.0, 3.0, 2.0, 1.0], f"Descending sort failed: {values}"
49        f_print_info("  Descending sort: OK")
explode (test_series_phase4.py:517)
507    except Exception as e:
508        f_print_error(f"combine_first failed: {e}")
509        return False
510
511
512def test_explode():
513    """Test Series explode"""
514    f_print_header("Test: Series explode")
515    try:
516        s = pandasCore.Series([1.0, 2.0, 3.0])
517        result = s.explode()
518        # For scalar types, explode returns same series
519        assert result.to_list() == [1.0, 2.0, 3.0], "explode should return same values for scalars"
520        f_print_success("explode: passed")
521        return True
522    except Exception as e:
523        f_print_error(f"explode failed: {e}")
524        return False
525
526
527def test_repeat():
swapaxes (test_series_phase5.py:252)
242def test_swapaxes():
243    """Test Series swapaxes method"""
244    f_print_header("Test: Series swapaxes")
245
246    try:
247        s = pandasCore.Series([1.0, 2.0, 3.0])
248
249        # swapaxes is no-op for Series
250        result = s.swapaxes(0, 0)
251        assert result.to_list() == s.to_list(), "swapaxes should return same values"
252        f_print_info(f"  swapaxes(0, 0): {result.to_list()}")
253
254        f_print_success("Series swapaxes: passed")
255        return True
256    except Exception as e:
257        f_print_error(f"Series swapaxes failed: {e}")
258        return False
to_frame (test_series.py:309)
299def test_series_to_frame():
300    """Test Series to_frame method"""
301    f_print_header("Test: Series to_frame")
302
303    try:
304        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
305
306        # Convert to DataFrame
307        df = s.to_frame()
308        assert df is not None, "to_frame should return DataFrame"
309        assert len(df) == 3, f"DataFrame should have 3 rows, got {len(df)}"
310
311        # With custom column name
312        df2 = s.to_frame(name="custom")
313        assert df2 is not None, "to_frame with name should return DataFrame"
314
315        f_print_success("Series to_frame: passed")
316        return True
317    except Exception as e:
transpose (test_series_phase5.py:209)
199def test_transpose():
200    """Test Series transpose method"""
201    f_print_header("Test: Series transpose")
202
203    try:
204        s = pandasCore.Series([1.0, 2.0, 3.0])
205
206        # transpose is no-op for Series
207        transposed = s.transpose()
208        assert transposed.to_list() == s.to_list(), "transpose should return same values"
209        f_print_info(f"  transpose(): {transposed.to_list()}")
210
211        # T property
212        transposed = s.T
213        assert transposed.to_list() == s.to_list(), "T property should return same values"
214        f_print_info(f"  .T property: {transposed.to_list()}")
215
216        f_print_success("Series transpose: passed")
217        return True
unstack (test_series_phase5.py:271)
261def test_unstack():
262    """Test Series unstack method"""
263    f_print_header("Test: Series unstack")
264
265    try:
266        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
267
268        # unstack returns DataFrame
269        result = s.unstack()
270        # Result should be a DataFrame (check for DataFrame-specific attributes)
271        # Note: ncols is a method, not an attribute, in pandasCore
272        is_dataframe = hasattr(result, 'columns') or hasattr(result, 'nrows')
273        assert is_dataframe, "unstack should return DataFrame"
274        f_print_info(f"  unstack(): returned DataFrame")
275
276        f_print_success("Series unstack: passed")
277        return True
278    except Exception as e:
279        f_print_error(f"Series unstack failed: {e}")
asfreq (test_series_phase5.py:404)
394# ============================================================================
395
396def test_time_series_placeholders():
397    """Test Series time series placeholders"""
398    f_print_header("Test: Series time series placeholders")
399
400    try:
401        s = pandasCore.Series([1.0, 2.0, 3.0])
402
403        # asfreq returns copy - use positional argument (pybind11 requirement)
404        result = s.asfreq("D")
405        assert len(result) == 3, "asfreq should return copy"
406        f_print_info("  asfreq: returns copy")
407
408        # at_time returns copy
409        result = s.at_time(time="09:30")
410        assert len(result) == 3, "at_time should return copy"
411        f_print_info("  at_time: returns copy")
412
413        # between_time returns copy
414        result = s.between_time(start_time="09:00", end_time="17:00")
asof (test_series_phase5.py:528)
518def test_asof():
519    """Test Series asof method"""
520    f_print_header("Test: Series asof")
521
522    try:
523        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
524
525        # asof returns last value
526        result = s.asof("5")
527        assert result == 5.0, f"asof should return last value, got {result}"
528        f_print_info(f"  asof('5'): {result}")
529
530        f_print_success("Series asof: passed")
531        return True
532    except Exception as e:
533        f_print_error(f"Series asof failed: {e}")
534        return False
at_time (test_series_phase5.py:409)
399    try:
400        s = pandasCore.Series([1.0, 2.0, 3.0])
401
402        # asfreq returns copy - use positional argument (pybind11 requirement)
403        result = s.asfreq("D")
404        assert len(result) == 3, "asfreq should return copy"
405        f_print_info("  asfreq: returns copy")
406
407        # at_time returns copy
408        result = s.at_time(time="09:30")
409        assert len(result) == 3, "at_time should return copy"
410        f_print_info("  at_time: returns copy")
411
412        # between_time returns copy
413        result = s.between_time(start_time="09:00", end_time="17:00")
414        assert len(result) == 3, "between_time should return copy"
415        f_print_info("  between_time: returns copy")
416
417        # tz_localize returns copy
418        result = s.tz_localize(tz="UTC")
between_time (test_series_phase5.py:414)
404        result = s.asfreq("D")
405        assert len(result) == 3, "asfreq should return copy"
406        f_print_info("  asfreq: returns copy")
407
408        # at_time returns copy
409        result = s.at_time(time="09:30")
410        assert len(result) == 3, "at_time should return copy"
411        f_print_info("  at_time: returns copy")
412
413        # between_time returns copy
414        result = s.between_time(start_time="09:00", end_time="17:00")
415        assert len(result) == 3, "between_time should return copy"
416        f_print_info("  between_time: returns copy")
417
418        # tz_localize returns copy
419        result = s.tz_localize(tz="UTC")
420        assert len(result) == 3, "tz_localize should return copy"
421        f_print_info("  tz_localize: returns copy")
422
423        # tz_convert returns copy
424        result = s.tz_convert(tz="US/Eastern")
diff (test_series_phase3.py:343)
333        f_print_success(f"cummax: {values} == {expected}")
334        return True
335    f_print_error(f"cummax: {values} != {expected}")
336    return False
337
338
339def test_diff():
340    """Test Series.diff()"""
341    f_print_header("Test: diff")
342    s = pandasCore.Series([1.0, 2.0, 4.0, 7.0, 11.0])
343    result = s.diff()
344    values = result.values()
345    # First value should be NaN, rest are differences
346    if math.isnan(values[0]) and values[1:] == [1.0, 2.0, 3.0, 4.0]:
347        f_print_success(f"diff: first is NaN, rest are [1.0, 2.0, 3.0, 4.0]")
348        return True
349    f_print_error(f"diff: unexpected values {values}")
350    return False
351
352
353def test_pct_change():
first_valid_index (test_series_phase3.py:563)
553        f_print_success(f"any: {result} (has one non-zero)")
554        return True
555    f_print_error(f"any: {result} != True")
556    return False
557
558
559def test_first_valid_index():
560    """Test Series.first_valid_index()"""
561    f_print_header("Test: first_valid_index")
562    s = pandasCore.Series([1.0, 2.0, 3.0])
563    result = s.first_valid_index()
564    if result == 0:
565        f_print_success(f"first_valid_index: {result} == 0")
566        return True
567    f_print_error(f"first_valid_index: {result} != 0")
568    return False
569
570
571def test_last_valid_index():
572    """Test Series.last_valid_index()"""
573    f_print_header("Test: last_valid_index")
last_valid_index (test_series_phase3.py:575)
565        f_print_success(f"first_valid_index: {result} == 0")
566        return True
567    f_print_error(f"first_valid_index: {result} != 0")
568    return False
569
570
571def test_last_valid_index():
572    """Test Series.last_valid_index()"""
573    f_print_header("Test: last_valid_index")
574    s = pandasCore.Series([1.0, 2.0, 3.0])
575    result = s.last_valid_index()
576    if result == 2:
577        f_print_success(f"last_valid_index: {result} == 2")
578        return True
579    f_print_error(f"last_valid_index: {result} != 2")
580    return False
581
582
583def test_searchsorted():
584    """Test Series.searchsorted()"""
585    f_print_header("Test: searchsorted")
pct_change (test_series_phase3.py:357)
347        f_print_success(f"diff: first is NaN, rest are [1.0, 2.0, 3.0, 4.0]")
348        return True
349    f_print_error(f"diff: unexpected values {values}")
350    return False
351
352
353def test_pct_change():
354    """Test Series.pct_change()"""
355    f_print_header("Test: pct_change")
356    s = pandasCore.Series([100.0, 110.0, 121.0])
357    result = s.pct_change()
358    values = result.values()
359    # First should be NaN, second is 0.1, third is 0.1
360    if math.isnan(values[0]) and abs(values[1] - 0.1) < 1e-10 and abs(values[2] - 0.1) < 1e-10:
361        f_print_success(f"pct_change: NaN, 0.1, 0.1")
362        return True
363    f_print_error(f"pct_change: unexpected values {values}")
364    return False
365
366
367def test_corr():
shift (test_series_phase5.py:113)
103# ============================================================================
104
105def test_shift():
106    """Test Series shift method"""
107    f_print_header("Test: Series shift")
108
109    try:
110        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
111
112        # Shift forward by 1
113        shifted = s.shift(1)
114        values = shifted.to_list()
115        # First element should be NaN or some fill value (implementation dependent)
116        assert values[1:] == [1.0, 2.0, 3.0, 4.0], f"Shift(1) failed: {values}"
117        f_print_info(f"  shift(1): {values[:5]}")
118
119        # Shift backward by 1
120        shifted = s.shift(-1)
121        values = shifted.to_list()
122        assert values[:4] == [2.0, 3.0, 4.0, 5.0], f"Shift(-1) failed: {values}"
123        f_print_info(f"  shift(-1): {values[:5]}")
to_period (test_series_phase5.py:429)
419        result = s.tz_localize(tz="UTC")
420        assert len(result) == 3, "tz_localize should return copy"
421        f_print_info("  tz_localize: returns copy")
422
423        # tz_convert returns copy
424        result = s.tz_convert(tz="US/Eastern")
425        assert len(result) == 3, "tz_convert should return copy"
426        f_print_info("  tz_convert: returns copy")
427
428        # to_period returns copy
429        result = s.to_period()
430        assert len(result) == 3, "to_period should return copy"
431        f_print_info("  to_period: returns copy")
432
433        # to_timestamp returns copy
434        result = s.to_timestamp()
435        assert len(result) == 3, "to_timestamp should return copy"
436        f_print_info("  to_timestamp: returns copy")
437
438        f_print_success("Series time series placeholders: passed")
439        return True
to_timestamp (test_series_phase5.py:434)
424        result = s.tz_convert(tz="US/Eastern")
425        assert len(result) == 3, "tz_convert should return copy"
426        f_print_info("  tz_convert: returns copy")
427
428        # to_period returns copy
429        result = s.to_period()
430        assert len(result) == 3, "to_period should return copy"
431        f_print_info("  to_period: returns copy")
432
433        # to_timestamp returns copy
434        result = s.to_timestamp()
435        assert len(result) == 3, "to_timestamp should return copy"
436        f_print_info("  to_timestamp: returns copy")
437
438        f_print_success("Series time series placeholders: passed")
439        return True
440    except Exception as e:
441        f_print_error(f"Series time series placeholders failed: {e}")
442        return False
tz_convert (test_series_phase5.py:424)
414        result = s.between_time(start_time="09:00", end_time="17:00")
415        assert len(result) == 3, "between_time should return copy"
416        f_print_info("  between_time: returns copy")
417
418        # tz_localize returns copy
419        result = s.tz_localize(tz="UTC")
420        assert len(result) == 3, "tz_localize should return copy"
421        f_print_info("  tz_localize: returns copy")
422
423        # tz_convert returns copy
424        result = s.tz_convert(tz="US/Eastern")
425        assert len(result) == 3, "tz_convert should return copy"
426        f_print_info("  tz_convert: returns copy")
427
428        # to_period returns copy
429        result = s.to_period()
430        assert len(result) == 3, "to_period should return copy"
431        f_print_info("  to_period: returns copy")
432
433        # to_timestamp returns copy
434        result = s.to_timestamp()
tz_localize (test_series_phase5.py:419)
409        result = s.at_time(time="09:30")
410        assert len(result) == 3, "at_time should return copy"
411        f_print_info("  at_time: returns copy")
412
413        # between_time returns copy
414        result = s.between_time(start_time="09:00", end_time="17:00")
415        assert len(result) == 3, "between_time should return copy"
416        f_print_info("  between_time: returns copy")
417
418        # tz_localize returns copy
419        result = s.tz_localize(tz="UTC")
420        assert len(result) == 3, "tz_localize should return copy"
421        f_print_info("  tz_localize: returns copy")
422
423        # tz_convert returns copy
424        result = s.tz_convert(tz="US/Eastern")
425        assert len(result) == 3, "tz_convert should return copy"
426        f_print_info("  tz_convert: returns copy")
427
428        # to_period returns copy
429        result = s.to_period()
to_csv (test_series_phase4.py:549)
539        return False
540
541
542# ==================== I/O Tests ====================
543
544def test_to_csv():
545    """Test Series to_csv"""
546    f_print_header("Test: Series to_csv")
547    try:
548        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
549        csv_str = s.to_csv()
550        assert isinstance(csv_str, str), "to_csv should return a string"
551        assert "1" in csv_str, "CSV should contain value 1"
552        assert "2" in csv_str, "CSV should contain value 2"
553        f_print_success("to_csv: passed")
554        return True
555    except Exception as e:
556        f_print_error(f"to_csv failed: {e}")
557        return False
to_dict (test_series_phase4.py:625)
615    except Exception as e:
616        f_print_error(f"to_latex failed: {e}")
617        return False
618
619
620def test_to_dict():
621    """Test Series to_dict"""
622    f_print_header("Test: Series to_dict")
623    try:
624        s = pandasCore.Series([1.0, 2.0, 3.0])
625        result = s.to_dict()
626        assert isinstance(result, dict), "to_dict should return a dict"
627        assert len(result) == 3, f"Expected 3 items, got {len(result)}"
628        f_print_success("to_dict: passed")
629        return True
630    except Exception as e:
631        f_print_error(f"to_dict failed: {e}")
632        return False
633
634
635def test_tolist():
to_json (test_series_phase4.py:565)
555    except Exception as e:
556        f_print_error(f"to_csv failed: {e}")
557        return False
558
559
560def test_to_json():
561    """Test Series to_json"""
562    f_print_header("Test: Series to_json")
563    try:
564        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
565        json_str = s.to_json()
566        assert isinstance(json_str, str), "to_json should return a string"
567        # JSON should have values
568        assert "1" in json_str, "JSON should contain value 1"
569        f_print_success("to_json: passed")
570        return True
571    except Exception as e:
572        f_print_error(f"to_json failed: {e}")
573        return False
to_latex (test_series_phase4.py:610)
600    except Exception as e:
601        f_print_error(f"to_markdown failed: {e}")
602        return False
603
604
605def test_to_latex():
606    """Test Series to_latex"""
607    f_print_header("Test: Series to_latex")
608    try:
609        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
610        latex_str = s.to_latex()
611        assert isinstance(latex_str, str), "to_latex should return a string"
612        assert "tabular" in latex_str or "begin" in latex_str, "LaTeX should contain tabular"
613        f_print_success("to_latex: passed")
614        return True
615    except Exception as e:
616        f_print_error(f"to_latex failed: {e}")
617        return False
618
619
620def test_to_dict():
to_list (test_series.py:104)
 94def test_series_copy():
 95    """Test Series copy method"""
 96    f_print_header("Test: Series copy")
 97
 98    try:
 99        s = pandasCore.Series([1.0, 2.0, 3.0], name="original")
100
101        # Test deep copy (default)
102        s_copy = s.copy()
103        assert s_copy.to_list() == s.to_list(), "Deep copy values differ"
104        assert s_copy.name == s.name, "Deep copy name differs"
105
106        # Test shallow copy
107        s_shallow = s.copy(deep=False)
108        assert s_shallow.to_list() == s.to_list(), "Shallow copy values differ"
109
110        f_print_success("Series copy: passed")
111        return True
112    except Exception as e:
113        f_print_error(f"Series copy failed: {e}")
to_markdown (test_series_phase4.py:595)
585    except Exception as e:
586        f_print_error(f"to_string failed: {e}")
587        return False
588
589
590def test_to_markdown():
591    """Test Series to_markdown"""
592    f_print_header("Test: Series to_markdown")
593    try:
594        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
595        md_str = s.to_markdown()
596        assert isinstance(md_str, str), "to_markdown should return a string"
597        assert "|" in md_str, "Markdown should contain table separators"
598        f_print_success("to_markdown: passed")
599        return True
600    except Exception as e:
601        f_print_error(f"to_markdown failed: {e}")
602        return False
603
604
605def test_to_latex():
to_numpy (test_series_phase4.py:655)
645    except Exception as e:
646        f_print_error(f"tolist failed: {e}")
647        return False
648
649
650def test_to_numpy():
651    """Test Series to_numpy"""
652    f_print_header("Test: Series to_numpy")
653    try:
654        s = pandasCore.Series([1.0, 2.0, 3.0])
655        result = s.to_numpy()
656        # Returns list in our implementation
657        assert result == [1.0, 2.0, 3.0], f"Expected [1.0, 2.0, 3.0], got {result}"
658        f_print_success("to_numpy: passed")
659        return True
660    except Exception as e:
661        f_print_error(f"to_numpy failed: {e}")
662        return False
663
664
665def test_align():
to_string (test_series_phase4.py:581)
571    except Exception as e:
572        f_print_error(f"to_json failed: {e}")
573        return False
574
575
576def test_to_string():
577    """Test Series to_string"""
578    f_print_header("Test: Series to_string")
579    try:
580        s = pandasCore.Series([1.0, 2.0, 3.0], name="values")
581        str_result = s.to_string()
582        assert isinstance(str_result, str), "to_string should return a string"
583        f_print_success("to_string: passed")
584        return True
585    except Exception as e:
586        f_print_error(f"to_string failed: {e}")
587        return False
588
589
590def test_to_markdown():
591    """Test Series to_markdown"""
tolist (test_series_phase4.py:640)
630    except Exception as e:
631        f_print_error(f"to_dict failed: {e}")
632        return False
633
634
635def test_tolist():
636    """Test Series tolist (alias)"""
637    f_print_header("Test: Series tolist")
638    try:
639        s = pandasCore.Series([1.0, 2.0, 3.0])
640        result = s.tolist()
641        expected = [1.0, 2.0, 3.0]
642        assert result == expected, f"Expected {expected}, got {result}"
643        f_print_success("tolist: passed")
644        return True
645    except Exception as e:
646        f_print_error(f"tolist failed: {e}")
647        return False
648
649
650def test_to_numpy():
astype (test_series_phase5.py:190)
180def test_astype():
181    """Test Series astype method"""
182    f_print_header("Test: Series astype")
183
184    try:
185        s = pandasCore.Series([1.0, 2.0, 3.0])
186
187        # astype returns copy for float64 series
188        result = s.astype("int64")
189        assert len(result) == 3, f"astype result length incorrect"
190        f_print_info(f"  astype('int64'): {result.to_list()}")
191
192        f_print_success("Series astype: passed")
193        return True
194    except Exception as e:
195        f_print_error(f"Series astype failed: {e}")
196        return False
bool (test_missing_methods.py:77)
67        assert result == True, f"Expected True, got {result}"
68
69def test_series_bool_float():
70    """Test Series.bool for float Series (deprecated)"""
71    global tests_run
72    tests_run += 1
73    s = pandasCore.Series([1.0])
74
75    with warnings.catch_warnings(record=True) as w:
76        warnings.simplefilter("always")
77        result = s.bool()
78        assert result == True, f"Expected True, got {result}"
79
80def test_series_bool_int():
81    """Test IntSeries.bool (deprecated)"""
82    global tests_run
83    tests_run += 1
84    s = pandasCore.IntSeries([1])
85
86    with warnings.catch_warnings(record=True) as w:
87        warnings.simplefilter("always")
convert_dtypes (test_series_phase5.py:547)
537def test_convert_dtypes():
538    """Test Series convert_dtypes method"""
539    f_print_header("Test: Series convert_dtypes")
540
541    try:
542        s = pandasCore.Series([1.0, 2.0, 3.0])
543
544        # convert_dtypes returns copy for float64
545        result = s.convert_dtypes()
546        assert result.to_list() == s.to_list(), "convert_dtypes should return same values"
547        f_print_info(f"  convert_dtypes(): {result.to_list()}")
548
549        f_print_success("Series convert_dtypes: passed")
550        return True
551    except Exception as e:
552        f_print_error(f"Series convert_dtypes failed: {e}")
553        return False
copy (test_series.py:103)
 93def test_series_copy():
 94    """Test Series copy method"""
 95    f_print_header("Test: Series copy")
 96
 97    try:
 98        s = pandasCore.Series([1.0, 2.0, 3.0], name="original")
 99
100        # Test deep copy (default)
101        s_copy = s.copy()
102        assert s_copy.to_list() == s.to_list(), "Deep copy values differ"
103        assert s_copy.name == s.name, "Deep copy name differs"
104
105        # Test shallow copy
106        s_shallow = s.copy(deep=False)
107        assert s_shallow.to_list() == s.to_list(), "Shallow copy values differ"
108
109        f_print_success("Series copy: passed")
110        return True
111    except Exception as e:
infer_objects (test_series_phase5.py:566)
556def test_infer_objects():
557    """Test Series infer_objects method"""
558    f_print_header("Test: Series infer_objects")
559
560    try:
561        s = pandasCore.Series([1.0, 2.0, 3.0])
562
563        # infer_objects returns copy
564        result = s.infer_objects()
565        assert result.to_list() == s.to_list(), "infer_objects should return same values"
566        f_print_info(f"  infer_objects(): {result.to_list()}")
567
568        f_print_success("Series infer_objects: passed")
569        return True
570    except Exception as e:
571        f_print_error(f"Series infer_objects failed: {e}")
572        return False
view (test_series.py:373)
363def test_series_view():
364    """Test Series view method"""
365    f_print_header("Test: Series view")
366
367    try:
368        s = pandasCore.Series([1.0, 2.0, 3.0])
369
370        # view returns shallow copy
371        s_view = s.view()
372        assert s_view.to_list() == s.to_list(), "View should have same values"
373
374        f_print_success("Series view: passed")
375        return True
376    except Exception as e:
377        f_print_error(f"Series view failed: {e}")
378        return False
379
380
381def test_series_len():
items (test_series.py:143)
133        f_print_error(f"Series keys failed: {e}")
134        return False
135
136
137def test_series_items():
138    """Test Series items method"""
139    f_print_header("Test: Series items")
140
141    try:
142        s = pandasCore.Series([1.0, 2.0, 3.0])
143        items = s.items()
144
145        # Should return list of (index, value) tuples
146        assert len(items) == 3, f"Expected 3 items, got {len(items)}"
147        assert items[0] == ("0", 1.0), f"First item incorrect: {items[0]}"
148        assert items[1] == ("1", 2.0), f"Second item incorrect: {items[1]}"
149        assert items[2] == ("2", 3.0), f"Third item incorrect: {items[2]}"
150
151        f_print_success("Series items: passed")
152        return True
153    except Exception as e:
keys (test_series.py:124)
114        f_print_error(f"Series copy failed: {e}")
115        return False
116
117
118def test_series_keys():
119    """Test Series keys method"""
120    f_print_header("Test: Series keys")
121
122    try:
123        s = pandasCore.Series([1.0, 2.0, 3.0])
124        keys = s.keys()
125
126        # Default RangeIndex should give us ["0", "1", "2"]
127        assert len(keys) == 3, f"Expected 3 keys, got {len(keys)}"
128        assert keys == ["0", "1", "2"], f"Expected ['0', '1', '2'], got {keys}"
129
130        f_print_success("Series keys: passed")
131        return True
132    except Exception as e:
133        f_print_error(f"Series keys failed: {e}")
134        return False
drop_duplicates (test_series_phase2.py:223)
213def test_drop_duplicates():
214    """Test Series drop_duplicates method"""
215    f_print_header("Test: Series drop_duplicates")
216
217    try:
218        s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0])
219
220        # Drop duplicates keeping first
221        s_unique = s.drop_duplicates(keep="first")
222        assert len(s_unique) == 3, f"Expected 3 unique values, got {len(s_unique)}"
223        assert s_unique.to_list() == [1.0, 2.0, 3.0], f"Values incorrect: {s_unique.to_list()}"
224
225        f_print_success("drop_duplicates: passed")
226        return True
227    except Exception as e:
228        f_print_error(f"drop_duplicates failed: {e}")
229        return False
duplicated (test_series_phase2.py:242)
232def test_duplicated():
233    """Test Series duplicated method"""
234    f_print_header("Test: Series duplicated")
235
236    try:
237        s = pandasCore.Series([1.0, 2.0, 2.0, 3.0])
238
239        # Get duplicated mask
240        dup_mask = s.duplicated()
241        assert len(dup_mask) == 4, f"Expected 4 elements, got {len(dup_mask)}"
242        # First 2.0 is not duplicate, second is
243        assert dup_mask == [False, False, True, False], f"Unexpected mask: {dup_mask}"
244
245        f_print_success("duplicated: passed")
246        return True
247    except Exception as e:
248        f_print_error(f"duplicated failed: {e}")
249        return False
isin (test_series_phase2.py:624)
614def test_isin():
615    """Test Series isin method"""
616    f_print_header("Test: Series isin")
617
618    try:
619        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
620
621        # Check membership
622        result = s.isin([2.0, 4.0])
623        expected = [False, True, False, True, False]
624        assert result == expected, f"Expected {expected}, got {result}"
625
626        f_print_success("isin: passed")
627        return True
628    except Exception as e:
629        f_print_error(f"isin failed: {e}")
630        return False
unique (test_series_phase2.py:699)
689        return False
690
691
692def test_unique():
693    """Test Series unique method"""
694    f_print_header("Test: Series unique")
695
696    try:
697        s = pandasCore.Series([1.0, 2.0, 2.0, 3.0, 1.0, 3.0])
698
699        result = s.unique()
700        # Unique values in order of first appearance
701        assert len(result) == 3, f"Expected 3 unique values, got {len(result)}"
702        assert set(result) == {1.0, 2.0, 3.0}, f"Unexpected unique values: {result}"
703
704        f_print_success("unique: passed")
705        return True
706    except Exception as e:
707        f_print_error(f"unique failed: {e}")
708        return False
round (test_series_phase4.py:372)
362        return False
363
364
365def test_round():
366    """Test Series round"""
367    f_print_header("Test: Series round")
368    try:
369        s = pandasCore.Series([1.234, 2.567, 3.891])
370
371        # Round to 0 decimals
372        result = s.round(0)
373        expected = [1.0, 3.0, 4.0]
374        assert result.to_list() == expected, f"round(0): Expected {expected}, got {result.to_list()}"
375
376        # Round to 2 decimals
377        result = s.round(2)
378        expected = [1.23, 2.57, 3.89]
379        assert result.to_list() == expected, f"round(2): Expected {expected}, got {result.to_list()}"
380
381        f_print_success("round: passed")
382        return True
abs (test_series_phase4.py:355)
345        return False
346
347
348# ==================== Comparison & Other Tests ====================
349
350def test_abs():
351    """Test Series abs"""
352    f_print_header("Test: Series abs")
353    try:
354        s = pandasCore.Series([-1.0, 2.0, -3.0, 4.0])
355        result = s.abs()
356        expected = [1.0, 2.0, 3.0, 4.0]
357        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
358        f_print_success("abs: passed")
359        return True
360    except Exception as e:
361        f_print_error(f"abs failed: {e}")
362        return False
363
364
365def test_round():
add_prefix (test_series_phase2.py:120)
110def test_add_prefix():
111    """Test Series add_prefix method"""
112    f_print_header("Test: Series add_prefix")
113
114    try:
115        s = pandasCore.Series([1.0, 2.0, 3.0])
116
117        # Add prefix to index labels
118        s_prefixed = s.add_prefix("item_")
119        keys = s_prefixed.keys()
120        assert keys[0] == "item_0", f"Expected 'item_0', got {keys[0]}"
121        assert keys[1] == "item_1", f"Expected 'item_1', got {keys[1]}"
122
123        f_print_success("add_prefix: passed")
124        return True
125    except Exception as e:
126        f_print_error(f"add_prefix failed: {e}")
127        return False
add_suffix (test_series_phase2.py:140)
130def test_add_suffix():
131    """Test Series add_suffix method"""
132    f_print_header("Test: Series add_suffix")
133
134    try:
135        s = pandasCore.Series([1.0, 2.0, 3.0])
136
137        # Add suffix to index labels
138        s_suffixed = s.add_suffix("_item")
139        keys = s_suffixed.keys()
140        assert keys[0] == "0_item", f"Expected '0_item', got {keys[0]}"
141        assert keys[1] == "1_item", f"Expected '1_item', got {keys[1]}"
142
143        f_print_success("add_suffix: passed")
144        return True
145    except Exception as e:
146        f_print_error(f"add_suffix failed: {e}")
147        return False
all (test_series_phase3.py:539)
529        f_print_success(f"pipe(double_sum): {result} == 30.0")
530        return True
531    f_print_error(f"pipe(double_sum): {result} != 30.0")
532    return False
533
534
535def test_all():
536    """Test Series.all()"""
537    f_print_header("Test: all")
538    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
539    result = s.all()
540    if result == True:
541        f_print_success(f"all: {result} (all non-zero)")
542        return True
543    f_print_error(f"all: {result} != True")
544    return False
545
546
547def test_any():
548    """Test Series.any()"""
549    f_print_header("Test: any")
any (test_series_phase3.py:551)
541        f_print_success(f"all: {result} (all non-zero)")
542        return True
543    f_print_error(f"all: {result} != True")
544    return False
545
546
547def test_any():
548    """Test Series.any()"""
549    f_print_header("Test: any")
550    s = pandasCore.Series([0.0, 0.0, 0.0, 1.0, 0.0])
551    result = s.any()
552    if result == True:
553        f_print_success(f"any: {result} (has one non-zero)")
554        return True
555    f_print_error(f"any: {result} != True")
556    return False
557
558
559def test_first_valid_index():
560    """Test Series.first_valid_index()"""
561    f_print_header("Test: first_valid_index")
argmax (test_series_phase3.py:263)
253    result = s.idxmin()
254    # Index of 1.0 is "1" (position 1)
255    f_print_success(f"idxmin: {result}")
256    return True
257
258
259def test_argmax():
260    """Test Series.argmax()"""
261    f_print_header("Test: argmax")
262    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
263    result = s.argmax()
264    if result == 2:  # Position of 5.0
265        f_print_success(f"argmax: {result} == 2")
266        return True
267    f_print_error(f"argmax: {result} != 2")
268    return False
269
270
271def test_argmin():
272    """Test Series.argmin()"""
273    f_print_header("Test: argmin")
argmin (test_series_phase3.py:275)
265        f_print_success(f"argmax: {result} == 2")
266        return True
267    f_print_error(f"argmax: {result} != 2")
268    return False
269
270
271def test_argmin():
272    """Test Series.argmin()"""
273    f_print_header("Test: argmin")
274    s = pandasCore.Series([3.0, 1.0, 5.0, 2.0, 4.0])
275    result = s.argmin()
276    if result == 1:  # Position of 1.0
277        f_print_success(f"argmin: {result} == 1")
278        return True
279    f_print_error(f"argmin: {result} != 1")
280    return False
281
282
283def test_cumsum():
284    """Test Series.cumsum()"""
285    f_print_header("Test: cumsum")
autocorr (test_series_phase3.py:398)
388        f_print_success(f"cov: {result} > 0")
389        return True
390    f_print_error(f"cov: {result} not positive")
391    return False
392
393
394def test_autocorr():
395    """Test Series.autocorr()"""
396    f_print_header("Test: autocorr")
397    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
398    result = s.autocorr(1)
399    if result is not None:
400        f_print_success(f"autocorr: {result}")
401        return True
402    f_print_error("autocorr: returned None")
403    return False
404
405
406def test_rank():
407    """Test Series.rank()"""
408    f_print_header("Test: rank")
between (test_series_phase2.py:643)
633def test_between():
634    """Test Series between method"""
635    f_print_header("Test: Series between")
636
637    try:
638        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
639
640        # Check if values are between 2 and 4 (inclusive)
641        result = s.between(2.0, 4.0, inclusive="both")
642        expected = [False, True, True, True, False]
643        assert result == expected, f"Expected {expected}, got {result}"
644
645        # Test exclusive
646        result = s.between(2.0, 4.0, inclusive="neither")
647        expected = [False, False, True, False, False]
648        assert result == expected, f"Expected {expected}, got {result}"
649
650        f_print_success("between: passed")
651        return True
case_when (test_series_phase2.py:674)
664    try:
665        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
666
667        # Apply case_when with conditions
668        # In pandasCore, unmatched values become NaN (no default_value parameter)
669        caselist = [
670            ([True, False, False, False, False], 10.0),
671            ([False, True, True, False, False], 20.0),
672        ]
673        result = s.case_when(caselist)
674        result_list = result.to_list()
675        # First element: matches first condition -> 10.0
676        # Second, third: match second condition -> 20.0
677        # Fourth, fifth: no match -> NaN (pandasCore behavior)
678        assert result_list[0] == 10.0, f"First element should be 10.0, got {result_list[0]}"
679        assert result_list[1] == 20.0, f"Second element should be 20.0, got {result_list[1]}"
680        assert result_list[2] == 20.0, f"Third element should be 20.0, got {result_list[2]}"
681        assert math.isnan(result_list[3]), f"Fourth element should be NaN, got {result_list[3]}"
682        assert math.isnan(result_list[4]), f"Fifth element should be NaN, got {result_list[4]}"
clip (test_series_phase4.py:393)
383    except Exception as e:
384        f_print_error(f"round failed: {e}")
385        return False
386
387
388def test_clip():
389    """Test Series clip"""
390    f_print_header("Test: Series clip")
391    try:
392        s = pandasCore.Series([1.0, 5.0, 10.0, 15.0, 20.0])
393        result = s.clip(5.0, 15.0)
394        expected = [5.0, 5.0, 10.0, 15.0, 15.0]
395        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
396        f_print_success("clip: passed")
397        return True
398    except Exception as e:
399        f_print_error(f"clip failed: {e}")
400        return False
401
402
403def test_eq():
divide (test_series_phase4.py:338)
328        # Test subtract
329        result = s.subtract(5.0)
330        assert result.to_list() == [5.0, 15.0, 25.0], "subtract failed"
331
332        # Test multiply
333        result = s.multiply(2.0)
334        assert result.to_list() == [20.0, 40.0, 60.0], "multiply failed"
335
336        # Test divide
337        result = s.divide(2.0)
338        assert result.to_list() == [5.0, 10.0, 15.0], "divide failed"
339
340        f_print_success("arithmetic aliases: passed")
341        return True
342    except Exception as e:
343        f_print_error(f"arithmetic aliases failed: {e}")
344        return False
345
346
347# ==================== Comparison & Other Tests ====================
divmod (test_series_phase4.py:279)
269    except Exception as e:
270        f_print_error(f"rpow failed: {e}")
271        return False
272
273
274def test_divmod():
275    """Test Series divmod"""
276    f_print_header("Test: Series divmod")
277    try:
278        s = pandasCore.Series([10.0, 21.0, 35.0])
279        quot, rem = s.divmod(4.0)
280        expected_quot = [2.0, 5.0, 8.0]
281        expected_rem = [2.0, 1.0, 3.0]
282        assert quot.to_list() == expected_quot, f"Expected quot {expected_quot}, got {quot.to_list()}"
283        assert rem.to_list() == expected_rem, f"Expected rem {expected_rem}, got {rem.to_list()}"
284        f_print_success("divmod: passed")
285        return True
286    except Exception as e:
287        f_print_error(f"divmod failed: {e}")
288        return False
factorize (test_series_phase2.py:740)
730        return False
731
732
733def test_factorize():
734    """Test Series factorize method"""
735    f_print_header("Test: Series factorize")
736
737    try:
738        s = pandasCore.Series([3.0, 1.0, 2.0, 1.0, 3.0])
739
740        codes, uniques = s.factorize()
741
742        # Check codes are valid indices
743        assert len(codes) == 5, f"Expected 5 codes, got {len(codes)}"
744        assert len(uniques) == 3, f"Expected 3 unique values, got {len(uniques)}"
745
746        # Codes should map back to original values
747        for i, code in enumerate(codes):
748            if code >= 0:  # Not NaN
749                assert uniques[code] == s[i], f"Code {code} doesn't map to correct value"
filter (test_series_phase5.py:168)
158def test_filter():
159    """Test Series filter method"""
160    f_print_header("Test: Series filter")
161
162    try:
163        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
164
165        # Filter by items
166        filtered = s.filter(items=["0", "2", "4"])
167        f_print_info(f"  filter(items=['0','2','4']): {filtered.to_list()}")
168
169        # Filter by like (substring match)
170        filtered = s.filter(like="1")
171        f_print_info(f"  filter(like='1'): {filtered.to_list()}")
172
173        f_print_success("Series filter: passed")
174        return True
175    except Exception as e:
176        f_print_error(f"Series filter failed: {e}")
hist (test_series_phase5.py:645)
635def test_hist_placeholder():
636    """Test Series hist placeholder"""
637    f_print_header("Test: Series hist (placeholder)")
638
639    try:
640        s = pandasCore.Series([1.0, 2.0, 3.0])
641
642        # hist should raise error
643        try:
644            s.hist()
645            f_print_error("hist should raise error")
646            return False
647        except RuntimeError as e:
648            assert "matplotlib" in str(e).lower(), f"Wrong error message: {e}"
649            f_print_info("  hist raises expected matplotlib error")
650
651        f_print_success("Series hist placeholder: passed")
652        return True
653    except Exception as e:
654        f_print_error(f"Series hist placeholder failed: {e}")
info (test_series.py:188)
178def test_series_info():
179    """Test Series info method"""
180    f_print_header("Test: Series info")
181
182    try:
183        s = pandasCore.Series([1.0, 2.0, 3.0], name="test")
184
185        # info() prints to stdout, just verify it doesn't raise
186        s.info()
187
188        f_print_success("Series info: passed")
189        return True
190    except Exception as e:
191        f_print_error(f"Series info failed: {e}")
192        return False
193
194
195def test_series_memory_usage():
196    """Test Series memory_usage method"""
item (test_series.py:245)
235        return False
236
237
238def test_series_item():
239    """Test Series item method"""
240    f_print_header("Test: Series item")
241
242    try:
243        # Single element Series
244        s = pandasCore.Series([42.0])
245        val = s.item()
246        assert val == 42.0, f"Expected 42.0, got {val}"
247
248        # Multi-element Series should raise
249        s_multi = pandasCore.Series([1.0, 2.0])
250        try:
251            s_multi.item()
252            f_print_error("item() should raise for multi-element Series")
253            return False
254        except RuntimeError:
255            pass  # Expected
memory_usage (test_series.py:204)
194        return False
195
196
197def test_series_memory_usage():
198    """Test Series memory_usage method"""
199    f_print_header("Test: Series memory_usage")
200
201    try:
202        s = pandasCore.Series([1.0, 2.0, 3.0])
203
204        mem = s.memory_usage()
205        assert mem > 0, f"Expected positive memory usage, got {mem}"
206
207        # Without index
208        mem_no_idx = s.memory_usage(index=False)
209        assert mem_no_idx > 0, f"Expected positive memory usage (no index), got {mem_no_idx}"
210        assert mem >= mem_no_idx, "Memory with index should be >= without"
211
212        f_print_success("Series memory_usage: passed")
213        return True
214    except Exception as e:
multiply (test_series_phase4.py:334)
324    """Test arithmetic aliases (subtract, multiply, divide)"""
325    f_print_header("Test: Series arithmetic aliases")
326    try:
327        s = pandasCore.Series([10.0, 20.0, 30.0])
328
329        # Test subtract
330        result = s.subtract(5.0)
331        assert result.to_list() == [5.0, 15.0, 25.0], "subtract failed"
332
333        # Test multiply
334        result = s.multiply(2.0)
335        assert result.to_list() == [20.0, 40.0, 60.0], "multiply failed"
336
337        # Test divide
338        result = s.divide(2.0)
339        assert result.to_list() == [5.0, 10.0, 15.0], "divide failed"
340
341        f_print_success("arithmetic aliases: passed")
342        return True
343    except Exception as e:
344        f_print_error(f"arithmetic aliases failed: {e}")
product (test_series_phase3.py:57)
47        f_print_success(f"prod: {result} == 120.0")
48        return True
49    f_print_error(f"prod: {result} != 120.0")
50    return False
51
52
53def test_product():
54    """Test Series.product() - alias for prod"""
55    f_print_header("Test: product")
56    s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
57    result = s.product()
58    if result == 120.0:
59        f_print_success(f"product: {result} == 120.0")
60        return True
61    f_print_error(f"product: {result} != 120.0")
62    return False
63
64
65def test_mean():
66    """Test Series.mean()"""
67    f_print_header("Test: mean")
ravel (test_series_phase5.py:233)
223def test_ravel():
224    """Test Series ravel method"""
225    f_print_header("Test: Series ravel")
226
227    try:
228        s = pandasCore.Series([1.0, 2.0, 3.0])
229
230        # ravel returns flattened array (list)
231        result = s.ravel()
232        assert result == [1.0, 2.0, 3.0], f"ravel failed: {result}"
233        f_print_info(f"  ravel(): {result}")
234
235        f_print_success("Series ravel: passed")
236        return True
237    except Exception as e:
238        f_print_error(f"Series ravel failed: {e}")
239        return False
rdivmod (test_series_phase4.py:296)
286    except Exception as e:
287        f_print_error(f"divmod failed: {e}")
288        return False
289
290
291def test_rdivmod():
292    """Test Series rdivmod"""
293    f_print_header("Test: Series rdivmod")
294    try:
295        s = pandasCore.Series([3.0, 4.0, 5.0])
296        quot, rem = s.rdivmod(10.0)  # divmod(10, [3, 4, 5])
297        expected_quot = [3.0, 2.0, 2.0]
298        expected_rem = [1.0, 2.0, 0.0]
299        assert quot.to_list() == expected_quot, f"Expected quot {expected_quot}, got {quot.to_list()}"
300        assert rem.to_list() == expected_rem, f"Expected rem {expected_rem}, got {rem.to_list()}"
301        f_print_success("rdivmod: passed")
302        return True
303    except Exception as e:
304        f_print_error(f"rdivmod failed: {e}")
305        return False
repeat (test_series_phase4.py:532)
522    except Exception as e:
523        f_print_error(f"explode failed: {e}")
524        return False
525
526
527def test_repeat():
528    """Test Series repeat"""
529    f_print_header("Test: Series repeat")
530    try:
531        s = pandasCore.Series([1.0, 2.0, 3.0])
532        result = s.repeat(2)
533        expected = [1.0, 1.0, 2.0, 2.0, 3.0, 3.0]
534        assert result.to_list() == expected, f"Expected {expected}, got {result.to_list()}"
535        f_print_success("repeat: passed")
536        return True
537    except Exception as e:
538        f_print_error(f"repeat failed: {e}")
539        return False
540
541
542# ==================== I/O Tests ====================
set_flags (test_series.py:291)
281def test_series_set_flags():
282    """Test Series set_flags method"""
283    f_print_header("Test: Series set_flags")
284
285    try:
286        s = pandasCore.Series([1.0, 2.0, 3.0])
287
288        # set_flags returns a copy (our simplified implementation)
289        s_flagged = s.set_flags()
290        assert s_flagged.to_list() == s.to_list(), "set_flags should return copy with same values"
291
292        f_print_success("Series set_flags: passed")
293        return True
294    except Exception as e:
295        f_print_error(f"Series set_flags failed: {e}")
296        return False
297
298
299def test_series_to_frame():
subtract (test_series_phase4.py:330)
320        return False
321
322
323def test_aliases():
324    """Test arithmetic aliases (subtract, multiply, divide)"""
325    f_print_header("Test: Series arithmetic aliases")
326    try:
327        s = pandasCore.Series([10.0, 20.0, 30.0])
328
329        # Test subtract
330        result = s.subtract(5.0)
331        assert result.to_list() == [5.0, 15.0, 25.0], "subtract failed"
332
333        # Test multiply
334        result = s.multiply(2.0)
335        assert result.to_list() == [20.0, 40.0, 60.0], "multiply failed"
336
337        # Test divide
338        result = s.divide(2.0)
339        assert result.to_list() == [5.0, 10.0, 15.0], "divide failed"
truncate (test_series_phase5.py:146)
136def test_truncate():
137    """Test Series truncate method"""
138    f_print_header("Test: Series truncate")
139
140    try:
141        s = pandasCore.Series([1.0, 2.0, 3.0, 4.0, 5.0])
142
143        # Truncate with before
144        truncated = s.truncate(before="1")
145        f_print_info(f"  truncate(before='1'): {truncated.to_list()}")
146
147        # Truncate with after
148        truncated = s.truncate(after="3")
149        f_print_info(f"  truncate(after='3'): {truncated.to_list()}")
150
151        f_print_success("Series truncate: passed")
152        return True
153    except Exception as e:
154        f_print_error(f"Series truncate failed: {e}")
values (test_accessor_descriptor.py:111)
101def test_string_series_str_accessor():
102    """Test that StringSeries.str accessor works on instance"""
103    f_print_header("Test: StringSeries instance str accessor")
104
105    try:
106        # Create StringSeries
107        data = ["HELLO", "world", "Test"]
108        s = pandasCore.StringSeries(data, name="test_strings")
109        f_print_success(f"Created StringSeries: {s.values()}")
110
111        # Access .str on instance should return StringAccessor
112        str_accessor = s.str
113        type_name = type(str_accessor).__name__
114        f_print_info(f"type(s.str).__name__ = {type_name}")
115
116        if type_name == "StringAccessor":
117            f_print_success("s.str returns StringAccessor")
118        else:
119            f_print_error(f"Expected StringAccessor, got {type_name}")