├── .pre-commit-config.yaml ├── AUTHORS.md ├── LICENSE ├── LICENSES ├── BOTTLENECK_LICENCE ├── DATEUTIL_LICENSE ├── HAVEN_LICENSE ├── HAVEN_MIT ├── KLIB_LICENSE ├── MUSL_LICENSE ├── NUMPY_LICENSE ├── PACKAGING_LICENSE ├── PSF_LICENSE ├── PYPERCLIP_LICENSE ├── PYUPGRADE_LICENSE ├── SAS7BDAT_LICENSE └── ULTRAJSON_LICENSE ├── README.md ├── generate_pxi.py ├── generate_version.py ├── meson.build ├── pandas ├── __init__.py ├── _config │ ├── __init__.py │ ├── config.py │ ├── dates.py │ ├── display.py │ └── localization.py ├── _libs │ ├── __init__.py │ ├── algos.pxd │ ├── algos.pyi │ ├── algos.pyx │ ├── algos_common_helper.pxi.in │ ├── algos_take_helper.pxi.in │ ├── arrays.pxd │ ├── arrays.pyi │ ├── arrays.pyx │ ├── byteswap.pyi │ ├── byteswap.pyx │ ├── dtypes.pxd │ ├── free_threading_config.pxi.in │ ├── groupby.pyi │ ├── groupby.pyx │ ├── hashing.pyi │ ├── hashing.pyx │ ├── hashtable.pxd │ ├── hashtable.pyi │ ├── hashtable.pyx │ ├── hashtable_class_helper.pxi.in │ ├── hashtable_func_helper.pxi.in │ ├── include │ │ └── pandas │ │ │ ├── datetime │ │ │ ├── date_conversions.h │ │ │ └── pd_datetime.h │ │ │ ├── parser │ │ │ ├── io.h │ │ │ ├── pd_parser.h │ │ │ └── tokenizer.h │ │ │ ├── portable.h │ │ │ ├── skiplist.h │ │ │ └── vendored │ │ │ ├── klib │ │ │ ├── khash.h │ │ │ └── khash_python.h │ │ │ ├── numpy │ │ │ └── datetime │ │ │ │ ├── np_datetime.h │ │ │ │ └── np_datetime_strings.h │ │ │ └── ujson │ │ │ └── lib │ │ │ └── ultrajson.h │ ├── index.pyi │ ├── index.pyx │ ├── index_class_helper.pxi.in │ ├── indexing.pyi │ ├── indexing.pyx │ ├── internals.pyi │ ├── internals.pyx │ ├── interval.pyi │ ├── interval.pyx │ ├── intervaltree.pxi.in │ ├── join.pyi │ ├── join.pyx │ ├── json.pyi │ ├── khash.pxd │ ├── khash_for_primitive_helper.pxi.in │ ├── lib.pxd │ ├── lib.pyi │ ├── lib.pyx │ ├── meson.build │ ├── missing.pxd │ ├── missing.pyi │ ├── missing.pyx │ ├── ops.pyi │ ├── ops.pyx │ ├── ops_dispatch.pyi │ ├── ops_dispatch.pyx │ ├── parsers.pyi │ ├── parsers.pyx │ ├── properties.pyi │ ├── properties.pyx │ ├── reshape.pyi │ ├── reshape.pyx │ ├── sas.pyi │ ├── sas.pyx │ ├── sparse.pyi │ ├── sparse.pyx │ ├── sparse_op_helper.pxi.in │ ├── src │ │ ├── datetime │ │ │ ├── date_conversions.c │ │ │ └── pd_datetime.c │ │ ├── parser │ │ │ ├── io.c │ │ │ ├── pd_parser.c │ │ │ └── tokenizer.c │ │ └── vendored │ │ │ ├── numpy │ │ │ └── datetime │ │ │ │ ├── np_datetime.c │ │ │ │ └── np_datetime_strings.c │ │ │ └── ujson │ │ │ ├── lib │ │ │ ├── ultrajsondec.c │ │ │ └── ultrajsonenc.c │ │ │ └── python │ │ │ ├── JSONtoObj.c │ │ │ ├── objToJSON.c │ │ │ └── ujson.c │ ├── testing.pyi │ ├── testing.pyx │ ├── tslib.pyi │ ├── tslib.pyx │ ├── tslibs │ │ ├── __init__.py │ │ ├── base.pxd │ │ ├── base.pyx │ │ ├── ccalendar.pxd │ │ ├── ccalendar.pyi │ │ ├── ccalendar.pyx │ │ ├── conversion.pxd │ │ ├── conversion.pyi │ │ ├── conversion.pyx │ │ ├── dtypes.pxd │ │ ├── dtypes.pyi │ │ ├── dtypes.pyx │ │ ├── fields.pyi │ │ ├── fields.pyx │ │ ├── meson.build │ │ ├── nattype.pxd │ │ ├── nattype.pyi │ │ ├── nattype.pyx │ │ ├── np_datetime.pxd │ │ ├── np_datetime.pyi │ │ ├── np_datetime.pyx │ │ ├── offsets.pxd │ │ ├── offsets.pyi │ │ ├── offsets.pyx │ │ ├── parsing.pxd │ │ ├── parsing.pyi │ │ ├── parsing.pyx │ │ ├── period.pxd │ │ ├── period.pyi │ │ ├── period.pyx │ │ ├── strptime.pxd │ │ ├── strptime.pyi │ │ ├── strptime.pyx │ │ ├── timedeltas.pxd │ │ ├── timedeltas.pyi │ │ ├── timedeltas.pyx │ │ ├── timestamps.pxd │ │ ├── timestamps.pyi │ │ ├── timestamps.pyx │ │ ├── timezones.pxd │ │ ├── timezones.pyi │ │ ├── timezones.pyx │ │ ├── tzconversion.pxd │ │ ├── tzconversion.pyi │ │ ├── tzconversion.pyx │ │ ├── util.pxd │ │ ├── vectorized.pyi │ │ └── vectorized.pyx │ ├── util.pxd │ ├── window │ │ ├── __init__.py │ │ ├── aggregations.pyi │ │ ├── aggregations.pyx │ │ ├── indexers.pyi │ │ ├── indexers.pyx │ │ └── meson.build │ ├── writers.pyi │ └── writers.pyx ├── _testing │ ├── __init__.py │ ├── _hypothesis.py │ ├── _io.py │ ├── _warnings.py │ ├── asserters.py │ ├── compat.py │ └── contexts.py ├── _typing.py ├── _version.py ├── api │ ├── __init__.py │ ├── executors │ │ └── __init__.py │ ├── extensions │ │ └── __init__.py │ ├── indexers │ │ └── __init__.py │ ├── interchange │ │ └── __init__.py │ ├── internals.py │ ├── types │ │ └── __init__.py │ └── typing │ │ └── __init__.py ├── arrays │ └── __init__.py ├── compat │ ├── __init__.py │ ├── _constants.py │ ├── _optional.py │ ├── numpy │ │ ├── __init__.py │ │ └── function.py │ ├── pickle_compat.py │ └── pyarrow.py ├── conftest.py ├── core │ ├── __init__.py │ ├── _numba │ │ ├── __init__.py │ │ ├── executor.py │ │ ├── extensions.py │ │ └── kernels │ │ │ ├── __init__.py │ │ │ ├── mean_.py │ │ │ ├── min_max_.py │ │ │ ├── shared.py │ │ │ ├── sum_.py │ │ │ └── var_.py │ ├── accessor.py │ ├── algorithms.py │ ├── api.py │ ├── apply.py │ ├── array_algos │ │ ├── __init__.py │ │ ├── datetimelike_accumulations.py │ │ ├── masked_accumulations.py │ │ ├── masked_reductions.py │ │ ├── putmask.py │ │ ├── quantile.py │ │ ├── replace.py │ │ ├── take.py │ │ └── transforms.py │ ├── arraylike.py │ ├── arrays │ │ ├── __init__.py │ │ ├── _arrow_string_mixins.py │ │ ├── _mixins.py │ │ ├── _ranges.py │ │ ├── _utils.py │ │ ├── arrow │ │ │ ├── __init__.py │ │ │ ├── _arrow_utils.py │ │ │ ├── accessors.py │ │ │ ├── array.py │ │ │ └── extension_types.py │ │ ├── base.py │ │ ├── boolean.py │ │ ├── categorical.py │ │ ├── datetimelike.py │ │ ├── datetimes.py │ │ ├── floating.py │ │ ├── integer.py │ │ ├── interval.py │ │ ├── masked.py │ │ ├── numeric.py │ │ ├── numpy_.py │ │ ├── period.py │ │ ├── sparse │ │ │ ├── __init__.py │ │ │ ├── accessor.py │ │ │ ├── array.py │ │ │ └── scipy_sparse.py │ │ ├── string_.py │ │ ├── string_arrow.py │ │ └── timedeltas.py │ ├── base.py │ ├── common.py │ ├── computation │ │ ├── __init__.py │ │ ├── align.py │ │ ├── api.py │ │ ├── check.py │ │ ├── common.py │ │ ├── engines.py │ │ ├── eval.py │ │ ├── expr.py │ │ ├── expressions.py │ │ ├── ops.py │ │ ├── parsing.py │ │ ├── pytables.py │ │ └── scope.py │ ├── config_init.py │ ├── construction.py │ ├── dtypes │ │ ├── __init__.py │ │ ├── api.py │ │ ├── astype.py │ │ ├── base.py │ │ ├── cast.py │ │ ├── common.py │ │ ├── concat.py │ │ ├── dtypes.py │ │ ├── generic.py │ │ ├── inference.py │ │ └── missing.py │ ├── flags.py │ ├── frame.py │ ├── generic.py │ ├── groupby │ │ ├── __init__.py │ │ ├── base.py │ │ ├── categorical.py │ │ ├── generic.py │ │ ├── groupby.py │ │ ├── grouper.py │ │ ├── indexing.py │ │ ├── numba_.py │ │ └── ops.py │ ├── indexers │ │ ├── __init__.py │ │ ├── objects.py │ │ └── utils.py │ ├── indexes │ │ ├── __init__.py │ │ ├── accessors.py │ │ ├── api.py │ │ ├── base.py │ │ ├── category.py │ │ ├── datetimelike.py │ │ ├── datetimes.py │ │ ├── extension.py │ │ ├── frozen.py │ │ ├── interval.py │ │ ├── multi.py │ │ ├── period.py │ │ ├── range.py │ │ └── timedeltas.py │ ├── indexing.py │ ├── interchange │ │ ├── __init__.py │ │ ├── buffer.py │ │ ├── column.py │ │ ├── dataframe.py │ │ ├── dataframe_protocol.py │ │ ├── from_dataframe.py │ │ └── utils.py │ ├── internals │ │ ├── __init__.py │ │ ├── api.py │ │ ├── blocks.py │ │ ├── concat.py │ │ ├── construction.py │ │ ├── managers.py │ │ └── ops.py │ ├── methods │ │ ├── __init__.py │ │ ├── describe.py │ │ ├── selectn.py │ │ └── to_dict.py │ ├── missing.py │ ├── nanops.py │ ├── ops │ │ ├── __init__.py │ │ ├── array_ops.py │ │ ├── common.py │ │ ├── dispatch.py │ │ ├── docstrings.py │ │ ├── invalid.py │ │ ├── mask_ops.py │ │ └── missing.py │ ├── resample.py │ ├── reshape │ │ ├── __init__.py │ │ ├── api.py │ │ ├── concat.py │ │ ├── encoding.py │ │ ├── melt.py │ │ ├── merge.py │ │ ├── pivot.py │ │ ├── reshape.py │ │ └── tile.py │ ├── roperator.py │ ├── sample.py │ ├── series.py │ ├── shared_docs.py │ ├── sorting.py │ ├── sparse │ │ ├── __init__.py │ │ └── api.py │ ├── strings │ │ ├── __init__.py │ │ ├── accessor.py │ │ ├── base.py │ │ └── object_array.py │ ├── tools │ │ ├── __init__.py │ │ ├── datetimes.py │ │ ├── numeric.py │ │ ├── timedeltas.py │ │ └── times.py │ ├── util │ │ ├── __init__.py │ │ ├── hashing.py │ │ └── numba_.py │ └── window │ │ ├── __init__.py │ │ ├── common.py │ │ ├── doc.py │ │ ├── ewm.py │ │ ├── expanding.py │ │ ├── numba_.py │ │ ├── online.py │ │ └── rolling.py ├── errors │ ├── __init__.py │ └── cow.py ├── io │ ├── __init__.py │ ├── _util.py │ ├── api.py │ ├── clipboard │ │ └── __init__.py │ ├── clipboards.py │ ├── common.py │ ├── excel │ │ ├── __init__.py │ │ ├── _base.py │ │ ├── _calamine.py │ │ ├── _odfreader.py │ │ ├── _odswriter.py │ │ ├── _openpyxl.py │ │ ├── _pyxlsb.py │ │ ├── _util.py │ │ ├── _xlrd.py │ │ └── _xlsxwriter.py │ ├── feather_format.py │ ├── formats │ │ ├── __init__.py │ │ ├── _color_data.py │ │ ├── console.py │ │ ├── css.py │ │ ├── csvs.py │ │ ├── excel.py │ │ ├── format.py │ │ ├── html.py │ │ ├── info.py │ │ ├── printing.py │ │ ├── string.py │ │ ├── style.py │ │ ├── style_render.py │ │ ├── templates │ │ │ ├── html.tpl │ │ │ ├── html_style.tpl │ │ │ ├── html_table.tpl │ │ │ ├── latex.tpl │ │ │ ├── latex_longtable.tpl │ │ │ ├── latex_table.tpl │ │ │ ├── string.tpl │ │ │ └── typst.tpl │ │ └── xml.py │ ├── html.py │ ├── iceberg.py │ ├── json │ │ ├── __init__.py │ │ ├── _json.py │ │ ├── _normalize.py │ │ └── _table_schema.py │ ├── orc.py │ ├── parquet.py │ ├── parsers │ │ ├── __init__.py │ │ ├── arrow_parser_wrapper.py │ │ ├── base_parser.py │ │ ├── c_parser_wrapper.py │ │ ├── python_parser.py │ │ └── readers.py │ ├── pickle.py │ ├── pytables.py │ ├── sas │ │ ├── __init__.py │ │ ├── sas7bdat.py │ │ ├── sas_constants.py │ │ ├── sas_xport.py │ │ └── sasreader.py │ ├── spss.py │ ├── sql.py │ ├── stata.py │ └── xml.py ├── meson.build ├── plotting │ ├── __init__.py │ ├── _core.py │ ├── _matplotlib │ │ ├── __init__.py │ │ ├── boxplot.py │ │ ├── converter.py │ │ ├── core.py │ │ ├── groupby.py │ │ ├── hist.py │ │ ├── misc.py │ │ ├── style.py │ │ ├── timeseries.py │ │ └── tools.py │ └── _misc.py ├── testing.py ├── tests │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ ├── test_api.py │ │ └── test_types.py │ ├── apply │ │ ├── __init__.py │ │ ├── common.py │ │ ├── conftest.py │ │ ├── test_frame_apply.py │ │ ├── test_frame_apply_relabeling.py │ │ ├── test_frame_transform.py │ │ ├── test_invalid_arg.py │ │ ├── test_numba.py │ │ ├── test_series_apply.py │ │ ├── test_series_apply_relabeling.py │ │ ├── test_series_transform.py │ │ └── test_str.py │ ├── arithmetic │ │ ├── __init__.py │ │ ├── common.py │ │ ├── conftest.py │ │ ├── test_array_ops.py │ │ ├── test_categorical.py │ │ ├── test_datetime64.py │ │ ├── test_interval.py │ │ ├── test_numeric.py │ │ ├── test_object.py │ │ ├── test_period.py │ │ └── test_timedelta64.py │ ├── arrays │ │ ├── __init__.py │ │ ├── boolean │ │ │ ├── __init__.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_astype.py │ │ │ ├── test_comparison.py │ │ │ ├── test_construction.py │ │ │ ├── test_function.py │ │ │ ├── test_indexing.py │ │ │ ├── test_logical.py │ │ │ ├── test_ops.py │ │ │ ├── test_reduction.py │ │ │ └── test_repr.py │ │ ├── categorical │ │ │ ├── __init__.py │ │ │ ├── test_algos.py │ │ │ ├── test_analytics.py │ │ │ ├── test_api.py │ │ │ ├── test_astype.py │ │ │ ├── test_constructors.py │ │ │ ├── test_dtypes.py │ │ │ ├── test_indexing.py │ │ │ ├── test_map.py │ │ │ ├── test_missing.py │ │ │ ├── test_operators.py │ │ │ ├── test_replace.py │ │ │ ├── test_repr.py │ │ │ ├── test_sorting.py │ │ │ ├── test_subclass.py │ │ │ ├── test_take.py │ │ │ └── test_warnings.py │ │ ├── datetimes │ │ │ ├── __init__.py │ │ │ ├── test_constructors.py │ │ │ ├── test_cumulative.py │ │ │ └── test_reductions.py │ │ ├── floating │ │ │ ├── __init__.py │ │ │ ├── conftest.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_astype.py │ │ │ ├── test_comparison.py │ │ │ ├── test_concat.py │ │ │ ├── test_construction.py │ │ │ ├── test_contains.py │ │ │ ├── test_function.py │ │ │ ├── test_repr.py │ │ │ └── test_to_numpy.py │ │ ├── integer │ │ │ ├── __init__.py │ │ │ ├── conftest.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_comparison.py │ │ │ ├── test_concat.py │ │ │ ├── test_construction.py │ │ │ ├── test_dtypes.py │ │ │ ├── test_function.py │ │ │ ├── test_indexing.py │ │ │ ├── test_reduction.py │ │ │ └── test_repr.py │ │ ├── interval │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ ├── test_formats.py │ │ │ ├── test_interval.py │ │ │ ├── test_interval_pyarrow.py │ │ │ └── test_overlaps.py │ │ ├── masked │ │ │ ├── __init__.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_arrow_compat.py │ │ │ ├── test_function.py │ │ │ └── test_indexing.py │ │ ├── masked_shared.py │ │ ├── numpy_ │ │ │ ├── __init__.py │ │ │ ├── test_indexing.py │ │ │ └── test_numpy.py │ │ ├── period │ │ │ ├── __init__.py │ │ │ ├── test_arrow_compat.py │ │ │ ├── test_astype.py │ │ │ ├── test_constructors.py │ │ │ └── test_reductions.py │ │ ├── sparse │ │ │ ├── __init__.py │ │ │ ├── test_accessor.py │ │ │ ├── test_arithmetics.py │ │ │ ├── test_array.py │ │ │ ├── test_astype.py │ │ │ ├── test_combine_concat.py │ │ │ ├── test_constructors.py │ │ │ ├── test_dtype.py │ │ │ ├── test_indexing.py │ │ │ ├── test_libsparse.py │ │ │ ├── test_reductions.py │ │ │ └── test_unary.py │ │ ├── string_ │ │ │ ├── __init__.py │ │ │ ├── test_concat.py │ │ │ ├── test_string.py │ │ │ └── test_string_arrow.py │ │ ├── test_array.py │ │ ├── test_datetimelike.py │ │ ├── test_datetimes.py │ │ ├── test_ndarray_backed.py │ │ ├── test_period.py │ │ ├── test_timedeltas.py │ │ └── timedeltas │ │ │ ├── __init__.py │ │ │ ├── test_constructors.py │ │ │ ├── test_cumulative.py │ │ │ └── test_reductions.py │ ├── base │ │ ├── __init__.py │ │ ├── common.py │ │ ├── test_constructors.py │ │ ├── test_conversion.py │ │ ├── test_fillna.py │ │ ├── test_misc.py │ │ ├── test_transpose.py │ │ ├── test_unique.py │ │ └── test_value_counts.py │ ├── computation │ │ ├── __init__.py │ │ ├── test_compat.py │ │ └── test_eval.py │ ├── config │ │ ├── __init__.py │ │ ├── test_config.py │ │ └── test_localization.py │ ├── construction │ │ ├── __init__.py │ │ └── test_extract_array.py │ ├── copy_view │ │ ├── __init__.py │ │ ├── index │ │ │ ├── __init__.py │ │ │ ├── test_datetimeindex.py │ │ │ ├── test_index.py │ │ │ ├── test_periodindex.py │ │ │ └── test_timedeltaindex.py │ │ ├── test_array.py │ │ ├── test_astype.py │ │ ├── test_chained_assignment_deprecation.py │ │ ├── test_clip.py │ │ ├── test_constructors.py │ │ ├── test_copy_deprecation.py │ │ ├── test_core_functionalities.py │ │ ├── test_functions.py │ │ ├── test_indexing.py │ │ ├── test_internals.py │ │ ├── test_interp_fillna.py │ │ ├── test_methods.py │ │ ├── test_replace.py │ │ ├── test_setitem.py │ │ ├── test_util.py │ │ └── util.py │ ├── dtypes │ │ ├── __init__.py │ │ ├── cast │ │ │ ├── __init__.py │ │ │ ├── test_can_hold_element.py │ │ │ ├── test_construct_from_scalar.py │ │ │ ├── test_construct_ndarray.py │ │ │ ├── test_construct_object_arr.py │ │ │ ├── test_dict_compat.py │ │ │ ├── test_downcast.py │ │ │ ├── test_find_common_type.py │ │ │ ├── test_infer_datetimelike.py │ │ │ ├── test_infer_dtype.py │ │ │ ├── test_maybe_box_native.py │ │ │ └── test_promote.py │ │ ├── test_common.py │ │ ├── test_concat.py │ │ ├── test_dtypes.py │ │ ├── test_generic.py │ │ ├── test_inference.py │ │ └── test_missing.py │ ├── extension │ │ ├── __init__.py │ │ ├── array_with_attr │ │ │ ├── __init__.py │ │ │ ├── array.py │ │ │ └── test_array_with_attr.py │ │ ├── base │ │ │ ├── __init__.py │ │ │ ├── accumulate.py │ │ │ ├── base.py │ │ │ ├── casting.py │ │ │ ├── constructors.py │ │ │ ├── dim2.py │ │ │ ├── dtype.py │ │ │ ├── getitem.py │ │ │ ├── groupby.py │ │ │ ├── index.py │ │ │ ├── interface.py │ │ │ ├── io.py │ │ │ ├── methods.py │ │ │ ├── missing.py │ │ │ ├── ops.py │ │ │ ├── printing.py │ │ │ ├── reduce.py │ │ │ ├── reshaping.py │ │ │ └── setitem.py │ │ ├── conftest.py │ │ ├── date │ │ │ ├── __init__.py │ │ │ └── array.py │ │ ├── decimal │ │ │ ├── __init__.py │ │ │ ├── array.py │ │ │ └── test_decimal.py │ │ ├── json │ │ │ ├── __init__.py │ │ │ ├── array.py │ │ │ └── test_json.py │ │ ├── list │ │ │ ├── __init__.py │ │ │ ├── array.py │ │ │ └── test_list.py │ │ ├── test_arrow.py │ │ ├── test_categorical.py │ │ ├── test_common.py │ │ ├── test_datetime.py │ │ ├── test_extension.py │ │ ├── test_interval.py │ │ ├── test_masked.py │ │ ├── test_numpy.py │ │ ├── test_period.py │ │ ├── test_sparse.py │ │ └── test_string.py │ ├── frame │ │ ├── __init__.py │ │ ├── common.py │ │ ├── conftest.py │ │ ├── constructors │ │ │ ├── __init__.py │ │ │ ├── test_from_dict.py │ │ │ └── test_from_records.py │ │ ├── indexing │ │ │ ├── __init__.py │ │ │ ├── test_coercion.py │ │ │ ├── test_delitem.py │ │ │ ├── test_get.py │ │ │ ├── test_get_value.py │ │ │ ├── test_getitem.py │ │ │ ├── test_indexing.py │ │ │ ├── test_insert.py │ │ │ ├── test_mask.py │ │ │ ├── test_set_value.py │ │ │ ├── test_setitem.py │ │ │ ├── test_take.py │ │ │ ├── test_where.py │ │ │ └── test_xs.py │ │ ├── methods │ │ │ ├── __init__.py │ │ │ ├── test_add_prefix_suffix.py │ │ │ ├── test_align.py │ │ │ ├── test_asfreq.py │ │ │ ├── test_asof.py │ │ │ ├── test_assign.py │ │ │ ├── test_astype.py │ │ │ ├── test_at_time.py │ │ │ ├── test_between_time.py │ │ │ ├── test_clip.py │ │ │ ├── test_combine.py │ │ │ ├── test_combine_first.py │ │ │ ├── test_compare.py │ │ │ ├── test_convert_dtypes.py │ │ │ ├── test_copy.py │ │ │ ├── test_count.py │ │ │ ├── test_cov_corr.py │ │ │ ├── test_describe.py │ │ │ ├── test_diff.py │ │ │ ├── test_dot.py │ │ │ ├── test_drop.py │ │ │ ├── test_drop_duplicates.py │ │ │ ├── test_droplevel.py │ │ │ ├── test_dropna.py │ │ │ ├── test_dtypes.py │ │ │ ├── test_duplicated.py │ │ │ ├── test_equals.py │ │ │ ├── test_explode.py │ │ │ ├── test_fillna.py │ │ │ ├── test_filter.py │ │ │ ├── test_first_valid_index.py │ │ │ ├── test_get_numeric_data.py │ │ │ ├── test_head_tail.py │ │ │ ├── test_infer_objects.py │ │ │ ├── test_info.py │ │ │ ├── test_interpolate.py │ │ │ ├── test_is_homogeneous_dtype.py │ │ │ ├── test_isetitem.py │ │ │ ├── test_isin.py │ │ │ ├── test_iterrows.py │ │ │ ├── test_join.py │ │ │ ├── test_map.py │ │ │ ├── test_matmul.py │ │ │ ├── test_nlargest.py │ │ │ ├── test_pct_change.py │ │ │ ├── test_pipe.py │ │ │ ├── test_pop.py │ │ │ ├── test_quantile.py │ │ │ ├── test_rank.py │ │ │ ├── test_reindex.py │ │ │ ├── test_reindex_like.py │ │ │ ├── test_rename.py │ │ │ ├── test_rename_axis.py │ │ │ ├── test_reorder_levels.py │ │ │ ├── test_replace.py │ │ │ ├── test_reset_index.py │ │ │ ├── test_round.py │ │ │ ├── test_sample.py │ │ │ ├── test_select_dtypes.py │ │ │ ├── test_set_axis.py │ │ │ ├── test_set_index.py │ │ │ ├── test_shift.py │ │ │ ├── test_size.py │ │ │ ├── test_sort_index.py │ │ │ ├── test_sort_values.py │ │ │ ├── test_swaplevel.py │ │ │ ├── test_to_csv.py │ │ │ ├── test_to_dict.py │ │ │ ├── test_to_dict_of_blocks.py │ │ │ ├── test_to_numpy.py │ │ │ ├── test_to_period.py │ │ │ ├── test_to_records.py │ │ │ ├── test_to_timestamp.py │ │ │ ├── test_transpose.py │ │ │ ├── test_truncate.py │ │ │ ├── test_tz_convert.py │ │ │ ├── test_tz_localize.py │ │ │ ├── test_update.py │ │ │ ├── test_value_counts.py │ │ │ └── test_values.py │ │ ├── test_alter_axes.py │ │ ├── test_api.py │ │ ├── test_arithmetic.py │ │ ├── test_arrow_interface.py │ │ ├── test_block_internals.py │ │ ├── test_constructors.py │ │ ├── test_cumulative.py │ │ ├── test_iteration.py │ │ ├── test_logical_ops.py │ │ ├── test_nonunique_indexes.py │ │ ├── test_npfuncs.py │ │ ├── test_query_eval.py │ │ ├── test_reductions.py │ │ ├── test_repr.py │ │ ├── test_stack_unstack.py │ │ ├── test_subclass.py │ │ ├── test_ufunc.py │ │ ├── test_unary.py │ │ └── test_validate.py │ ├── generic │ │ ├── __init__.py │ │ ├── test_duplicate_labels.py │ │ ├── test_finalize.py │ │ ├── test_frame.py │ │ ├── test_generic.py │ │ ├── test_label_or_level_utils.py │ │ ├── test_series.py │ │ └── test_to_xarray.py │ ├── groupby │ │ ├── __init__.py │ │ ├── aggregate │ │ │ ├── __init__.py │ │ │ ├── test_aggregate.py │ │ │ ├── test_cython.py │ │ │ ├── test_numba.py │ │ │ └── test_other.py │ │ ├── conftest.py │ │ ├── methods │ │ │ ├── __init__.py │ │ │ ├── test_describe.py │ │ │ ├── test_groupby_shift_diff.py │ │ │ ├── test_is_monotonic.py │ │ │ ├── test_kurt.py │ │ │ ├── test_nlargest_nsmallest.py │ │ │ ├── test_nth.py │ │ │ ├── test_quantile.py │ │ │ ├── test_rank.py │ │ │ ├── test_sample.py │ │ │ ├── test_size.py │ │ │ ├── test_skew.py │ │ │ └── test_value_counts.py │ │ ├── test_all_methods.py │ │ ├── test_api.py │ │ ├── test_apply.py │ │ ├── test_bin_groupby.py │ │ ├── test_categorical.py │ │ ├── test_counting.py │ │ ├── test_cumulative.py │ │ ├── test_filters.py │ │ ├── test_groupby.py │ │ ├── test_groupby_dropna.py │ │ ├── test_groupby_subclass.py │ │ ├── test_grouping.py │ │ ├── test_index_as_string.py │ │ ├── test_indexing.py │ │ ├── test_libgroupby.py │ │ ├── test_missing.py │ │ ├── test_numba.py │ │ ├── test_numeric_only.py │ │ ├── test_pipe.py │ │ ├── test_raises.py │ │ ├── test_reductions.py │ │ ├── test_timegrouper.py │ │ └── transform │ │ │ ├── __init__.py │ │ │ ├── test_numba.py │ │ │ └── test_transform.py │ ├── indexes │ │ ├── __init__.py │ │ ├── base_class │ │ │ ├── __init__.py │ │ │ ├── test_constructors.py │ │ │ ├── test_formats.py │ │ │ ├── test_indexing.py │ │ │ ├── test_pickle.py │ │ │ ├── test_reshape.py │ │ │ ├── test_setops.py │ │ │ └── test_where.py │ │ ├── categorical │ │ │ ├── __init__.py │ │ │ ├── test_append.py │ │ │ ├── test_astype.py │ │ │ ├── test_category.py │ │ │ ├── test_constructors.py │ │ │ ├── test_equals.py │ │ │ ├── test_fillna.py │ │ │ ├── test_formats.py │ │ │ ├── test_indexing.py │ │ │ ├── test_map.py │ │ │ ├── test_reindex.py │ │ │ └── test_setops.py │ │ ├── conftest.py │ │ ├── datetimelike_ │ │ │ ├── __init__.py │ │ │ ├── test_drop_duplicates.py │ │ │ ├── test_equals.py │ │ │ ├── test_indexing.py │ │ │ ├── test_is_monotonic.py │ │ │ ├── test_nat.py │ │ │ ├── test_sort_values.py │ │ │ └── test_value_counts.py │ │ ├── datetimes │ │ │ ├── __init__.py │ │ │ ├── methods │ │ │ │ ├── __init__.py │ │ │ │ ├── test_asof.py │ │ │ │ ├── test_astype.py │ │ │ │ ├── test_delete.py │ │ │ │ ├── test_factorize.py │ │ │ │ ├── test_fillna.py │ │ │ │ ├── test_insert.py │ │ │ │ ├── test_isocalendar.py │ │ │ │ ├── test_map.py │ │ │ │ ├── test_normalize.py │ │ │ │ ├── test_repeat.py │ │ │ │ ├── test_resolution.py │ │ │ │ ├── test_round.py │ │ │ │ ├── test_shift.py │ │ │ │ ├── test_snap.py │ │ │ │ ├── test_to_frame.py │ │ │ │ ├── test_to_julian_date.py │ │ │ │ ├── test_to_period.py │ │ │ │ ├── test_to_pydatetime.py │ │ │ │ ├── test_to_series.py │ │ │ │ ├── test_tz_convert.py │ │ │ │ ├── test_tz_localize.py │ │ │ │ └── test_unique.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_constructors.py │ │ │ ├── test_date_range.py │ │ │ ├── test_datetime.py │ │ │ ├── test_formats.py │ │ │ ├── test_freq_attr.py │ │ │ ├── test_indexing.py │ │ │ ├── test_iter.py │ │ │ ├── test_join.py │ │ │ ├── test_npfuncs.py │ │ │ ├── test_ops.py │ │ │ ├── test_partial_slicing.py │ │ │ ├── test_pickle.py │ │ │ ├── test_reindex.py │ │ │ ├── test_scalar_compat.py │ │ │ ├── test_setops.py │ │ │ └── test_timezones.py │ │ ├── interval │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ ├── test_constructors.py │ │ │ ├── test_equals.py │ │ │ ├── test_formats.py │ │ │ ├── test_indexing.py │ │ │ ├── test_interval.py │ │ │ ├── test_interval_range.py │ │ │ ├── test_interval_tree.py │ │ │ ├── test_join.py │ │ │ ├── test_pickle.py │ │ │ └── test_setops.py │ │ ├── multi │ │ │ ├── __init__.py │ │ │ ├── conftest.py │ │ │ ├── test_analytics.py │ │ │ ├── test_astype.py │ │ │ ├── test_compat.py │ │ │ ├── test_constructors.py │ │ │ ├── test_conversion.py │ │ │ ├── test_copy.py │ │ │ ├── test_drop.py │ │ │ ├── test_duplicates.py │ │ │ ├── test_equivalence.py │ │ │ ├── test_formats.py │ │ │ ├── test_get_level_values.py │ │ │ ├── test_get_set.py │ │ │ ├── test_indexing.py │ │ │ ├── test_integrity.py │ │ │ ├── test_isin.py │ │ │ ├── test_join.py │ │ │ ├── test_lexsort.py │ │ │ ├── test_missing.py │ │ │ ├── test_monotonic.py │ │ │ ├── test_names.py │ │ │ ├── test_partial_indexing.py │ │ │ ├── test_pickle.py │ │ │ ├── test_reindex.py │ │ │ ├── test_reshape.py │ │ │ ├── test_setops.py │ │ │ ├── test_sorting.py │ │ │ ├── test_take.py │ │ │ └── test_util.py │ │ ├── numeric │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ ├── test_indexing.py │ │ │ ├── test_join.py │ │ │ ├── test_numeric.py │ │ │ └── test_setops.py │ │ ├── object │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ └── test_indexing.py │ │ ├── period │ │ │ ├── __init__.py │ │ │ ├── methods │ │ │ │ ├── __init__.py │ │ │ │ ├── test_asfreq.py │ │ │ │ ├── test_astype.py │ │ │ │ ├── test_factorize.py │ │ │ │ ├── test_fillna.py │ │ │ │ ├── test_insert.py │ │ │ │ ├── test_is_full.py │ │ │ │ ├── test_repeat.py │ │ │ │ ├── test_shift.py │ │ │ │ └── test_to_timestamp.py │ │ │ ├── test_constructors.py │ │ │ ├── test_formats.py │ │ │ ├── test_freq_attr.py │ │ │ ├── test_indexing.py │ │ │ ├── test_join.py │ │ │ ├── test_monotonic.py │ │ │ ├── test_partial_slicing.py │ │ │ ├── test_period.py │ │ │ ├── test_period_range.py │ │ │ ├── test_pickle.py │ │ │ ├── test_resolution.py │ │ │ ├── test_scalar_compat.py │ │ │ ├── test_searchsorted.py │ │ │ ├── test_setops.py │ │ │ └── test_tools.py │ │ ├── ranges │ │ │ ├── __init__.py │ │ │ ├── test_constructors.py │ │ │ ├── test_indexing.py │ │ │ ├── test_join.py │ │ │ ├── test_range.py │ │ │ └── test_setops.py │ │ ├── string │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ └── test_indexing.py │ │ ├── test_any_index.py │ │ ├── test_base.py │ │ ├── test_common.py │ │ ├── test_datetimelike.py │ │ ├── test_engines.py │ │ ├── test_frozen.py │ │ ├── test_index_new.py │ │ ├── test_indexing.py │ │ ├── test_numpy_compat.py │ │ ├── test_old_base.py │ │ ├── test_setops.py │ │ ├── test_subclass.py │ │ └── timedeltas │ │ │ ├── __init__.py │ │ │ ├── methods │ │ │ ├── __init__.py │ │ │ ├── test_astype.py │ │ │ ├── test_factorize.py │ │ │ ├── test_fillna.py │ │ │ ├── test_insert.py │ │ │ ├── test_repeat.py │ │ │ └── test_shift.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_constructors.py │ │ │ ├── test_delete.py │ │ │ ├── test_formats.py │ │ │ ├── test_freq_attr.py │ │ │ ├── test_indexing.py │ │ │ ├── test_join.py │ │ │ ├── test_ops.py │ │ │ ├── test_pickle.py │ │ │ ├── test_scalar_compat.py │ │ │ ├── test_searchsorted.py │ │ │ ├── test_setops.py │ │ │ ├── test_timedelta.py │ │ │ └── test_timedelta_range.py │ ├── indexing │ │ ├── __init__.py │ │ ├── common.py │ │ ├── interval │ │ │ ├── __init__.py │ │ │ ├── test_interval.py │ │ │ └── test_interval_new.py │ │ ├── multiindex │ │ │ ├── __init__.py │ │ │ ├── test_chaining_and_caching.py │ │ │ ├── test_datetime.py │ │ │ ├── test_getitem.py │ │ │ ├── test_iloc.py │ │ │ ├── test_indexing_slow.py │ │ │ ├── test_loc.py │ │ │ ├── test_multiindex.py │ │ │ ├── test_partial.py │ │ │ ├── test_setitem.py │ │ │ ├── test_slice.py │ │ │ └── test_sorted.py │ │ ├── test_at.py │ │ ├── test_categorical.py │ │ ├── test_chaining_and_caching.py │ │ ├── test_check_indexer.py │ │ ├── test_coercion.py │ │ ├── test_datetime.py │ │ ├── test_floats.py │ │ ├── test_iat.py │ │ ├── test_iloc.py │ │ ├── test_indexers.py │ │ ├── test_indexing.py │ │ ├── test_loc.py │ │ ├── test_na_indexing.py │ │ ├── test_partial.py │ │ └── test_scalar.py │ ├── interchange │ │ ├── __init__.py │ │ ├── test_impl.py │ │ ├── test_spec_conformance.py │ │ └── test_utils.py │ ├── internals │ │ ├── __init__.py │ │ ├── test_api.py │ │ └── test_internals.py │ ├── io │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── excel │ │ │ ├── __init__.py │ │ │ ├── test_odf.py │ │ │ ├── test_odswriter.py │ │ │ ├── test_openpyxl.py │ │ │ ├── test_readers.py │ │ │ ├── test_style.py │ │ │ ├── test_writers.py │ │ │ ├── test_xlrd.py │ │ │ └── test_xlsxwriter.py │ │ ├── formats │ │ │ ├── __init__.py │ │ │ ├── style │ │ │ │ ├── __init__.py │ │ │ │ ├── test_bar.py │ │ │ │ ├── test_exceptions.py │ │ │ │ ├── test_format.py │ │ │ │ ├── test_highlight.py │ │ │ │ ├── test_html.py │ │ │ │ ├── test_matplotlib.py │ │ │ │ ├── test_non_unique.py │ │ │ │ ├── test_style.py │ │ │ │ ├── test_to_latex.py │ │ │ │ ├── test_to_string.py │ │ │ │ ├── test_to_typst.py │ │ │ │ └── test_tooltip.py │ │ │ ├── test_console.py │ │ │ ├── test_css.py │ │ │ ├── test_eng_formatting.py │ │ │ ├── test_format.py │ │ │ ├── test_ipython_compat.py │ │ │ ├── test_printing.py │ │ │ ├── test_to_csv.py │ │ │ ├── test_to_excel.py │ │ │ ├── test_to_html.py │ │ │ ├── test_to_latex.py │ │ │ ├── test_to_markdown.py │ │ │ └── test_to_string.py │ │ ├── generate_legacy_storage_files.py │ │ ├── json │ │ │ ├── __init__.py │ │ │ ├── conftest.py │ │ │ ├── test_compression.py │ │ │ ├── test_deprecated_kwargs.py │ │ │ ├── test_json_table_schema.py │ │ │ ├── test_json_table_schema_ext_dtype.py │ │ │ ├── test_normalize.py │ │ │ ├── test_pandas.py │ │ │ ├── test_readlines.py │ │ │ └── test_ujson.py │ │ ├── parser │ │ │ ├── __init__.py │ │ │ ├── common │ │ │ │ ├── __init__.py │ │ │ │ ├── test_chunksize.py │ │ │ │ ├── test_common_basic.py │ │ │ │ ├── test_data_list.py │ │ │ │ ├── test_decimal.py │ │ │ │ ├── test_file_buffer_url.py │ │ │ │ ├── test_float.py │ │ │ │ ├── test_index.py │ │ │ │ ├── test_inf.py │ │ │ │ ├── test_ints.py │ │ │ │ ├── test_iterator.py │ │ │ │ └── test_read_errors.py │ │ │ ├── conftest.py │ │ │ ├── dtypes │ │ │ │ ├── __init__.py │ │ │ │ ├── test_categorical.py │ │ │ │ ├── test_dtypes_basic.py │ │ │ │ └── test_empty.py │ │ │ ├── test_c_parser_only.py │ │ │ ├── test_comment.py │ │ │ ├── test_compression.py │ │ │ ├── test_concatenate_chunks.py │ │ │ ├── test_converters.py │ │ │ ├── test_dialect.py │ │ │ ├── test_encoding.py │ │ │ ├── test_header.py │ │ │ ├── test_index_col.py │ │ │ ├── test_mangle_dupes.py │ │ │ ├── test_multi_thread.py │ │ │ ├── test_na_values.py │ │ │ ├── test_network.py │ │ │ ├── test_parse_dates.py │ │ │ ├── test_python_parser_only.py │ │ │ ├── test_quoting.py │ │ │ ├── test_read_fwf.py │ │ │ ├── test_skiprows.py │ │ │ ├── test_textreader.py │ │ │ ├── test_unsupported.py │ │ │ ├── test_upcast.py │ │ │ └── usecols │ │ │ │ ├── __init__.py │ │ │ │ ├── test_parse_dates.py │ │ │ │ ├── test_strings.py │ │ │ │ └── test_usecols_basic.py │ │ ├── pytables │ │ │ ├── __init__.py │ │ │ ├── common.py │ │ │ ├── conftest.py │ │ │ ├── test_append.py │ │ │ ├── test_categorical.py │ │ │ ├── test_compat.py │ │ │ ├── test_complex.py │ │ │ ├── test_errors.py │ │ │ ├── test_file_handling.py │ │ │ ├── test_keys.py │ │ │ ├── test_put.py │ │ │ ├── test_pytables_missing.py │ │ │ ├── test_read.py │ │ │ ├── test_retain_attributes.py │ │ │ ├── test_round_trip.py │ │ │ ├── test_select.py │ │ │ ├── test_store.py │ │ │ ├── test_subclass.py │ │ │ ├── test_time_series.py │ │ │ └── test_timezones.py │ │ ├── sas │ │ │ ├── __init__.py │ │ │ ├── test_byteswap.py │ │ │ ├── test_sas.py │ │ │ ├── test_sas7bdat.py │ │ │ └── test_xport.py │ │ ├── test_clipboard.py │ │ ├── test_common.py │ │ ├── test_compression.py │ │ ├── test_feather.py │ │ ├── test_fsspec.py │ │ ├── test_gcs.py │ │ ├── test_html.py │ │ ├── test_http_headers.py │ │ ├── test_iceberg.py │ │ ├── test_orc.py │ │ ├── test_parquet.py │ │ ├── test_pickle.py │ │ ├── test_s3.py │ │ ├── test_spss.py │ │ ├── test_sql.py │ │ ├── test_stata.py │ │ └── xml │ │ │ ├── __init__.py │ │ │ ├── conftest.py │ │ │ ├── test_to_xml.py │ │ │ ├── test_xml.py │ │ │ └── test_xml_dtypes.py │ ├── libs │ │ ├── __init__.py │ │ ├── test_hashtable.py │ │ ├── test_join.py │ │ ├── test_lib.py │ │ └── test_libalgos.py │ ├── plotting │ │ ├── __init__.py │ │ ├── common.py │ │ ├── conftest.py │ │ ├── frame │ │ │ ├── __init__.py │ │ │ ├── test_frame.py │ │ │ ├── test_frame_color.py │ │ │ ├── test_frame_groupby.py │ │ │ ├── test_frame_legend.py │ │ │ ├── test_frame_subplots.py │ │ │ └── test_hist_box_by.py │ │ ├── test_backend.py │ │ ├── test_boxplot_method.py │ │ ├── test_common.py │ │ ├── test_converter.py │ │ ├── test_datetimelike.py │ │ ├── test_groupby.py │ │ ├── test_hist_method.py │ │ ├── test_misc.py │ │ ├── test_series.py │ │ └── test_style.py │ ├── reductions │ │ ├── __init__.py │ │ ├── test_reductions.py │ │ └── test_stat_reductions.py │ ├── resample │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_base.py │ │ ├── test_datetime_index.py │ │ ├── test_period_index.py │ │ ├── test_resample_api.py │ │ ├── test_resampler_grouper.py │ │ ├── test_time_grouper.py │ │ └── test_timedelta.py │ ├── reshape │ │ ├── __init__.py │ │ ├── concat │ │ │ ├── __init__.py │ │ │ ├── test_append.py │ │ │ ├── test_append_common.py │ │ │ ├── test_categorical.py │ │ │ ├── test_concat.py │ │ │ ├── test_dataframe.py │ │ │ ├── test_datetimes.py │ │ │ ├── test_empty.py │ │ │ ├── test_index.py │ │ │ ├── test_invalid.py │ │ │ ├── test_series.py │ │ │ └── test_sort.py │ │ ├── merge │ │ │ ├── __init__.py │ │ │ ├── test_join.py │ │ │ ├── test_merge.py │ │ │ ├── test_merge_antijoin.py │ │ │ ├── test_merge_asof.py │ │ │ ├── test_merge_cross.py │ │ │ ├── test_merge_index_as_string.py │ │ │ ├── test_merge_ordered.py │ │ │ └── test_multi.py │ │ ├── test_crosstab.py │ │ ├── test_cut.py │ │ ├── test_from_dummies.py │ │ ├── test_get_dummies.py │ │ ├── test_melt.py │ │ ├── test_pivot.py │ │ ├── test_pivot_multilevel.py │ │ ├── test_qcut.py │ │ └── test_union_categoricals.py │ ├── scalar │ │ ├── __init__.py │ │ ├── interval │ │ │ ├── __init__.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_constructors.py │ │ │ ├── test_contains.py │ │ │ ├── test_formats.py │ │ │ ├── test_interval.py │ │ │ └── test_overlaps.py │ │ ├── period │ │ │ ├── __init__.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_asfreq.py │ │ │ └── test_period.py │ │ ├── test_na_scalar.py │ │ ├── test_nat.py │ │ ├── timedelta │ │ │ ├── __init__.py │ │ │ ├── methods │ │ │ │ ├── __init__.py │ │ │ │ ├── test_as_unit.py │ │ │ │ └── test_round.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_constructors.py │ │ │ ├── test_formats.py │ │ │ └── test_timedelta.py │ │ └── timestamp │ │ │ ├── __init__.py │ │ │ ├── methods │ │ │ ├── __init__.py │ │ │ ├── test_as_unit.py │ │ │ ├── test_normalize.py │ │ │ ├── test_replace.py │ │ │ ├── test_round.py │ │ │ ├── test_timestamp_method.py │ │ │ ├── test_to_julian_date.py │ │ │ ├── test_to_pydatetime.py │ │ │ ├── test_tz_convert.py │ │ │ └── test_tz_localize.py │ │ │ ├── test_arithmetic.py │ │ │ ├── test_comparisons.py │ │ │ ├── test_constructors.py │ │ │ ├── test_formats.py │ │ │ ├── test_timestamp.py │ │ │ └── test_timezones.py │ ├── series │ │ ├── __init__.py │ │ ├── accessors │ │ │ ├── __init__.py │ │ │ ├── test_cat_accessor.py │ │ │ ├── test_dt_accessor.py │ │ │ ├── test_list_accessor.py │ │ │ ├── test_sparse_accessor.py │ │ │ ├── test_str_accessor.py │ │ │ └── test_struct_accessor.py │ │ ├── indexing │ │ │ ├── __init__.py │ │ │ ├── test_datetime.py │ │ │ ├── test_delitem.py │ │ │ ├── test_get.py │ │ │ ├── test_getitem.py │ │ │ ├── test_indexing.py │ │ │ ├── test_mask.py │ │ │ ├── test_set_value.py │ │ │ ├── test_setitem.py │ │ │ ├── test_take.py │ │ │ ├── test_where.py │ │ │ └── test_xs.py │ │ ├── methods │ │ │ ├── __init__.py │ │ │ ├── test_add_prefix_suffix.py │ │ │ ├── test_align.py │ │ │ ├── test_argsort.py │ │ │ ├── test_asof.py │ │ │ ├── test_astype.py │ │ │ ├── test_autocorr.py │ │ │ ├── test_between.py │ │ │ ├── test_case_when.py │ │ │ ├── test_clip.py │ │ │ ├── test_combine.py │ │ │ ├── test_combine_first.py │ │ │ ├── test_compare.py │ │ │ ├── test_convert_dtypes.py │ │ │ ├── test_copy.py │ │ │ ├── test_count.py │ │ │ ├── test_cov_corr.py │ │ │ ├── test_describe.py │ │ │ ├── test_diff.py │ │ │ ├── test_drop.py │ │ │ ├── test_drop_duplicates.py │ │ │ ├── test_dropna.py │ │ │ ├── test_dtypes.py │ │ │ ├── test_duplicated.py │ │ │ ├── test_equals.py │ │ │ ├── test_explode.py │ │ │ ├── test_fillna.py │ │ │ ├── test_get_numeric_data.py │ │ │ ├── test_head_tail.py │ │ │ ├── test_infer_objects.py │ │ │ ├── test_info.py │ │ │ ├── test_interpolate.py │ │ │ ├── test_is_monotonic.py │ │ │ ├── test_is_unique.py │ │ │ ├── test_isin.py │ │ │ ├── test_isna.py │ │ │ ├── test_item.py │ │ │ ├── test_map.py │ │ │ ├── test_matmul.py │ │ │ ├── test_nlargest.py │ │ │ ├── test_nunique.py │ │ │ ├── test_pct_change.py │ │ │ ├── test_pop.py │ │ │ ├── test_quantile.py │ │ │ ├── test_rank.py │ │ │ ├── test_reindex.py │ │ │ ├── test_reindex_like.py │ │ │ ├── test_rename.py │ │ │ ├── test_rename_axis.py │ │ │ ├── test_repeat.py │ │ │ ├── test_replace.py │ │ │ ├── test_reset_index.py │ │ │ ├── test_round.py │ │ │ ├── test_searchsorted.py │ │ │ ├── test_set_name.py │ │ │ ├── test_size.py │ │ │ ├── test_sort_index.py │ │ │ ├── test_sort_values.py │ │ │ ├── test_to_csv.py │ │ │ ├── test_to_dict.py │ │ │ ├── test_to_frame.py │ │ │ ├── test_to_numpy.py │ │ │ ├── test_tolist.py │ │ │ ├── test_truncate.py │ │ │ ├── test_tz_localize.py │ │ │ ├── test_unique.py │ │ │ ├── test_unstack.py │ │ │ ├── test_update.py │ │ │ ├── test_value_counts.py │ │ │ └── test_values.py │ │ ├── test_api.py │ │ ├── test_arithmetic.py │ │ ├── test_arrow_interface.py │ │ ├── test_constructors.py │ │ ├── test_cumulative.py │ │ ├── test_formats.py │ │ ├── test_iteration.py │ │ ├── test_logical_ops.py │ │ ├── test_missing.py │ │ ├── test_npfuncs.py │ │ ├── test_reductions.py │ │ ├── test_subclass.py │ │ ├── test_ufunc.py │ │ ├── test_unary.py │ │ └── test_validate.py │ ├── strings │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_api.py │ │ ├── test_case_justify.py │ │ ├── test_cat.py │ │ ├── test_extract.py │ │ ├── test_find_replace.py │ │ ├── test_get_dummies.py │ │ ├── test_split_partition.py │ │ ├── test_string_array.py │ │ └── test_strings.py │ ├── test_aggregation.py │ ├── test_algos.py │ ├── test_common.py │ ├── test_downstream.py │ ├── test_errors.py │ ├── test_expressions.py │ ├── test_flags.py │ ├── test_multilevel.py │ ├── test_nanops.py │ ├── test_optional_dependency.py │ ├── test_register_accessor.py │ ├── test_sorting.py │ ├── test_take.py │ ├── tools │ │ ├── __init__.py │ │ ├── test_to_datetime.py │ │ ├── test_to_numeric.py │ │ ├── test_to_time.py │ │ └── test_to_timedelta.py │ ├── tseries │ │ ├── __init__.py │ │ ├── frequencies │ │ │ ├── __init__.py │ │ │ ├── test_freq_code.py │ │ │ ├── test_frequencies.py │ │ │ └── test_inference.py │ │ ├── holiday │ │ │ ├── __init__.py │ │ │ ├── test_calendar.py │ │ │ ├── test_federal.py │ │ │ ├── test_holiday.py │ │ │ └── test_observance.py │ │ └── offsets │ │ │ ├── __init__.py │ │ │ ├── common.py │ │ │ ├── test_business_day.py │ │ │ ├── test_business_halfyear.py │ │ │ ├── test_business_hour.py │ │ │ ├── test_business_month.py │ │ │ ├── test_business_quarter.py │ │ │ ├── test_business_year.py │ │ │ ├── test_common.py │ │ │ ├── test_custom_business_day.py │ │ │ ├── test_custom_business_hour.py │ │ │ ├── test_custom_business_month.py │ │ │ ├── test_dst.py │ │ │ ├── test_easter.py │ │ │ ├── test_fiscal.py │ │ │ ├── test_halfyear.py │ │ │ ├── test_index.py │ │ │ ├── test_month.py │ │ │ ├── test_offsets.py │ │ │ ├── test_offsets_properties.py │ │ │ ├── test_quarter.py │ │ │ ├── test_ticks.py │ │ │ ├── test_week.py │ │ │ └── test_year.py │ ├── tslibs │ │ ├── __init__.py │ │ ├── test_api.py │ │ ├── test_array_to_datetime.py │ │ ├── test_ccalendar.py │ │ ├── test_conversion.py │ │ ├── test_fields.py │ │ ├── test_libfrequencies.py │ │ ├── test_liboffsets.py │ │ ├── test_np_datetime.py │ │ ├── test_npy_units.py │ │ ├── test_parse_iso8601.py │ │ ├── test_parsing.py │ │ ├── test_period.py │ │ ├── test_resolution.py │ │ ├── test_strptime.py │ │ ├── test_timedeltas.py │ │ ├── test_timezones.py │ │ ├── test_to_offset.py │ │ └── test_tzconversion.py │ ├── util │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_assert_almost_equal.py │ │ ├── test_assert_attr_equal.py │ │ ├── test_assert_categorical_equal.py │ │ ├── test_assert_extension_array_equal.py │ │ ├── test_assert_frame_equal.py │ │ ├── test_assert_index_equal.py │ │ ├── test_assert_interval_array_equal.py │ │ ├── test_assert_numpy_array_equal.py │ │ ├── test_assert_produces_warning.py │ │ ├── test_assert_series_equal.py │ │ ├── test_deprecate.py │ │ ├── test_deprecate_kwarg.py │ │ ├── test_deprecate_nonkeyword_arguments.py │ │ ├── test_doc.py │ │ ├── test_hashing.py │ │ ├── test_numba.py │ │ ├── test_rewrite_warning.py │ │ ├── test_shares_memory.py │ │ ├── test_show_versions.py │ │ ├── test_util.py │ │ ├── test_validate_args.py │ │ ├── test_validate_args_and_kwargs.py │ │ ├── test_validate_inclusive.py │ │ └── test_validate_kwargs.py │ └── window │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── moments │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_moments_consistency_ewm.py │ │ ├── test_moments_consistency_expanding.py │ │ └── test_moments_consistency_rolling.py │ │ ├── test_api.py │ │ ├── test_apply.py │ │ ├── test_base_indexer.py │ │ ├── test_cython_aggregations.py │ │ ├── test_dtypes.py │ │ ├── test_ewm.py │ │ ├── test_expanding.py │ │ ├── test_groupby.py │ │ ├── test_numba.py │ │ ├── test_online.py │ │ ├── test_pairwise.py │ │ ├── test_rolling.py │ │ ├── test_rolling_functions.py │ │ ├── test_rolling_quantile.py │ │ ├── test_rolling_skew_kurt.py │ │ ├── test_timeseries_window.py │ │ └── test_win_type.py ├── tseries │ ├── __init__.py │ ├── api.py │ ├── frequencies.py │ ├── holiday.py │ └── offsets.py └── util │ ├── __init__.py │ ├── _decorators.py │ ├── _doctools.py │ ├── _exceptions.py │ ├── _print_versions.py │ ├── _test_decorators.py │ ├── _tester.py │ ├── _validators.py │ └── version │ └── __init__.py ├── pyproject.toml ├── scripts └── cibw_before_build.sh └── tooling └── debug ├── Dockerfile.pandas-debug └── README /LICENSES/HAVEN_LICENSE: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Hadley Wickham; RStudio; and Evan Miller 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/HAVEN_MIT: -------------------------------------------------------------------------------- 1 | Based on http://opensource.org/licenses/MIT 2 | 3 | This is a template. Complete and ship as file LICENSE the following 2 4 | lines (only) 5 | 6 | YEAR: 7 | COPYRIGHT HOLDER: 8 | 9 | and specify as 10 | 11 | License: MIT + file LICENSE 12 | 13 | Copyright (c) , 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining 16 | a copy of this software and associated documentation files (the 17 | "Software"), to deal in the Software without restriction, including 18 | without limitation the rights to use, copy, modify, merge, publish, 19 | distribute, sublicense, and/or sell copies of the Software, and to 20 | permit persons to whom the Software is furnished to do so, subject to 21 | the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be 24 | included in all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | -------------------------------------------------------------------------------- /LICENSES/KLIB_LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2008- Attractive Chaos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSES/PYUPGRADE_LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Anthony Sottile 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSES/SAS7BDAT_LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2019 Jared Hobbs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /generate_pxi.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | 4 | from Cython import Tempita 5 | 6 | 7 | def process_tempita(pxifile, outfile) -> None: 8 | with open(pxifile, encoding="utf-8") as f: 9 | tmpl = f.read() 10 | pyxcontent = Tempita.sub(tmpl) 11 | 12 | with open(outfile, "w", encoding="utf-8") as f: 13 | f.write(pyxcontent) 14 | 15 | 16 | def main() -> None: 17 | parser = argparse.ArgumentParser() 18 | parser.add_argument("infile", type=str, help="Path to the input file") 19 | parser.add_argument("-o", "--outdir", type=str, help="Path to the output directory") 20 | args = parser.parse_args() 21 | 22 | if not args.infile.endswith(".in"): 23 | raise ValueError(f"Unexpected extension: {args.infile}") 24 | 25 | outdir_abs = os.path.join(os.getcwd(), args.outdir) 26 | outfile = os.path.join( 27 | outdir_abs, os.path.splitext(os.path.split(args.infile)[1])[0] 28 | ) 29 | 30 | process_tempita(args.infile, outfile) 31 | 32 | 33 | main() 34 | -------------------------------------------------------------------------------- /pandas/_config/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | pandas._config is considered explicitly upstream of everything else in pandas, 3 | should have no intra-pandas dependencies. 4 | 5 | importing `dates` and `display` ensures that keys needed by _libs 6 | are initialized. 7 | """ 8 | 9 | __all__ = [ 10 | "config", 11 | "describe_option", 12 | "detect_console_encoding", 13 | "get_option", 14 | "option_context", 15 | "options", 16 | "reset_option", 17 | "set_option", 18 | ] 19 | from pandas._config import config 20 | from pandas._config import dates # pyright: ignore[reportUnusedImport] # noqa: F401 21 | from pandas._config.config import ( 22 | _global_config, 23 | describe_option, 24 | get_option, 25 | option_context, 26 | options, 27 | reset_option, 28 | set_option, 29 | ) 30 | from pandas._config.display import detect_console_encoding 31 | 32 | 33 | def using_string_dtype() -> bool: 34 | _mode_options = _global_config["future"] 35 | return _mode_options["infer_string"] 36 | -------------------------------------------------------------------------------- /pandas/_config/dates.py: -------------------------------------------------------------------------------- 1 | """ 2 | config for datetime formatting 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from pandas._config import config as cf 8 | 9 | pc_date_dayfirst_doc = """ 10 | : boolean 11 | When True, prints and parses dates with the day first, eg 20/01/2005 12 | """ 13 | 14 | pc_date_yearfirst_doc = """ 15 | : boolean 16 | When True, prints and parses dates with the year first, eg 2005/01/20 17 | """ 18 | 19 | with cf.config_prefix("display"): 20 | # Needed upstream of `_libs` because these are used in tslibs.parsing 21 | cf.register_option( 22 | "date_dayfirst", False, pc_date_dayfirst_doc, validator=cf.is_bool 23 | ) 24 | cf.register_option( 25 | "date_yearfirst", False, pc_date_yearfirst_doc, validator=cf.is_bool 26 | ) 27 | -------------------------------------------------------------------------------- /pandas/_libs/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | "Interval", 3 | "NaT", 4 | "NaTType", 5 | "OutOfBoundsDatetime", 6 | "Period", 7 | "Timedelta", 8 | "Timestamp", 9 | "iNaT", 10 | ] 11 | 12 | 13 | # Below imports needs to happen first to ensure pandas top level 14 | # module gets monkeypatched with the pandas_datetime_CAPI 15 | # see pandas_datetime_exec in pd_datetime.c 16 | import pandas._libs.pandas_parser # isort: skip # type: ignore[reportUnusedImport] 17 | import pandas._libs.pandas_datetime # noqa: F401 # isort: skip # type: ignore[reportUnusedImport] 18 | from pandas._libs.interval import Interval 19 | from pandas._libs.tslibs import ( 20 | NaT, 21 | NaTType, 22 | OutOfBoundsDatetime, 23 | Period, 24 | Timedelta, 25 | Timestamp, 26 | iNaT, 27 | ) 28 | -------------------------------------------------------------------------------- /pandas/_libs/algos.pxd: -------------------------------------------------------------------------------- 1 | from pandas._libs.dtypes cimport ( 2 | numeric_object_t, 3 | numeric_t, 4 | ) 5 | 6 | 7 | cdef numeric_t kth_smallest_c(numeric_t* arr, Py_ssize_t k, Py_ssize_t n) noexcept nogil 8 | 9 | cdef enum TiebreakEnumType: 10 | TIEBREAK_AVERAGE 11 | TIEBREAK_MIN, 12 | TIEBREAK_MAX 13 | TIEBREAK_FIRST 14 | TIEBREAK_FIRST_DESCENDING 15 | TIEBREAK_DENSE 16 | 17 | 18 | cdef numeric_object_t get_rank_nan_fill_val( 19 | bint rank_nans_highest, 20 | numeric_object_t val, 21 | bint is_datetimelike=*, 22 | ) 23 | -------------------------------------------------------------------------------- /pandas/_libs/arrays.pxd: -------------------------------------------------------------------------------- 1 | 2 | from numpy cimport ndarray 3 | 4 | 5 | cdef class NDArrayBacked: 6 | cdef: 7 | readonly ndarray _ndarray 8 | readonly object _dtype 9 | 10 | cpdef NDArrayBacked _from_backing_data(self, ndarray values) 11 | cpdef __setstate__(self, state) 12 | -------------------------------------------------------------------------------- /pandas/_libs/arrays.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Sequence 2 | 3 | import numpy as np 4 | 5 | from pandas._typing import ( 6 | AxisInt, 7 | DtypeObj, 8 | Self, 9 | Shape, 10 | ) 11 | 12 | class NDArrayBacked: 13 | _dtype: DtypeObj 14 | _ndarray: np.ndarray 15 | def __init__(self, values: np.ndarray, dtype: DtypeObj) -> None: ... 16 | @classmethod 17 | def _simple_new(cls, values: np.ndarray, dtype: DtypeObj) -> Self: ... 18 | def _from_backing_data(self, values: np.ndarray) -> Self: ... 19 | def __setstate__(self, state) -> None: ... 20 | def __len__(self) -> int: ... 21 | @property 22 | def shape(self) -> Shape: ... 23 | @property 24 | def ndim(self) -> int: ... 25 | @property 26 | def size(self) -> int: ... 27 | @property 28 | def nbytes(self) -> int: ... 29 | def copy(self, order=...) -> Self: ... 30 | def delete(self, loc, axis=...) -> Self: ... 31 | def swapaxes(self, axis1, axis2) -> Self: ... 32 | def repeat(self, repeats: int | Sequence[int], axis: int | None = ...) -> Self: ... 33 | def reshape(self, *args, **kwargs) -> Self: ... 34 | def ravel(self, order=...) -> Self: ... 35 | @property 36 | def T(self) -> Self: ... 37 | @classmethod 38 | def _concat_same_type( 39 | cls, to_concat: Sequence[Self], axis: AxisInt = ... 40 | ) -> Self: ... 41 | -------------------------------------------------------------------------------- /pandas/_libs/byteswap.pyi: -------------------------------------------------------------------------------- 1 | def read_float_with_byteswap(data: bytes, offset: int, byteswap: bool) -> float: ... 2 | def read_double_with_byteswap(data: bytes, offset: int, byteswap: bool) -> float: ... 3 | def read_uint16_with_byteswap(data: bytes, offset: int, byteswap: bool) -> int: ... 4 | def read_uint32_with_byteswap(data: bytes, offset: int, byteswap: bool) -> int: ... 5 | def read_uint64_with_byteswap(data: bytes, offset: int, byteswap: bool) -> int: ... 6 | -------------------------------------------------------------------------------- /pandas/_libs/dtypes.pxd: -------------------------------------------------------------------------------- 1 | """ 2 | Common location for shared fused types 3 | """ 4 | 5 | from numpy cimport ( 6 | float32_t, 7 | float64_t, 8 | int8_t, 9 | int16_t, 10 | int32_t, 11 | int64_t, 12 | uint8_t, 13 | uint16_t, 14 | uint32_t, 15 | uint64_t, 16 | ) 17 | 18 | # All numeric types except complex 19 | ctypedef fused numeric_t: 20 | int8_t 21 | int16_t 22 | int32_t 23 | int64_t 24 | 25 | uint8_t 26 | uint16_t 27 | uint32_t 28 | uint64_t 29 | 30 | float32_t 31 | float64_t 32 | 33 | # All numeric types + object, doesn't include complex 34 | ctypedef fused numeric_object_t: 35 | numeric_t 36 | object 37 | -------------------------------------------------------------------------------- /pandas/_libs/free_threading_config.pxi.in: -------------------------------------------------------------------------------- 1 | # Autogenerated file containing Cython compile-time defines 2 | 3 | DEF CYTHON_COMPATIBLE_WITH_FREE_THREADING = @freethreading_compatible@ 4 | -------------------------------------------------------------------------------- /pandas/_libs/hashing.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import npt 4 | 5 | def hash_object_array( 6 | arr: npt.NDArray[np.object_], 7 | key: str, 8 | encoding: str = ..., 9 | ) -> npt.NDArray[np.uint64]: ... 10 | -------------------------------------------------------------------------------- /pandas/_libs/include/pandas/datetime/date_conversions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2020, PyData Development Team 3 | All rights reserved. 4 | Distributed under the terms of the BSD Simplified License. 5 | The full license is in the LICENSE file, distributed with this software. 6 | */ 7 | 8 | #pragma once 9 | 10 | #define PY_SSIZE_T_CLEAN 11 | #include 12 | 13 | #include 14 | 15 | // Scales value inplace from nanosecond resolution to unit resolution 16 | int scaleNanosecToUnit(int64_t *value, NPY_DATETIMEUNIT unit); 17 | 18 | // Converts an int64 object representing a date to ISO format 19 | // up to precision `base` e.g. base="s" yields 2020-01-03T00:00:00Z 20 | // while base="ns" yields "2020-01-01T00:00:00.000000000Z" 21 | // len is mutated to save the length of the returned string 22 | char *int64ToIso(int64_t value, NPY_DATETIMEUNIT valueUnit, 23 | NPY_DATETIMEUNIT base, size_t *len); 24 | 25 | char *int64ToIsoDuration(int64_t value, size_t *len); 26 | -------------------------------------------------------------------------------- /pandas/_libs/include/pandas/parser/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, PyData Development Team 3 | All rights reserved. 4 | 5 | Distributed under the terms of the BSD Simplified License. 6 | 7 | The full license is in the LICENSE file, distributed with this software. 8 | */ 9 | 10 | #pragma once 11 | 12 | #define PY_SSIZE_T_CLEAN 13 | #include 14 | 15 | #include "tokenizer.h" 16 | 17 | #define FS(source) ((file_source *)source) 18 | 19 | typedef struct _rd_source { 20 | PyObject *obj; 21 | PyObject *buffer; 22 | size_t position; 23 | } rd_source; 24 | 25 | #define RDS(source) ((rd_source *)source) 26 | 27 | void *new_rd_source(PyObject *obj); 28 | 29 | void del_rd_source(void *src); 30 | 31 | char *buffer_rd_bytes(void *source, size_t nbytes, size_t *bytes_read, 32 | int *status, const char *encoding_errors); 33 | -------------------------------------------------------------------------------- /pandas/_libs/indexing.pyi: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Generic, 3 | TypeVar, 4 | ) 5 | 6 | from pandas.core.indexing import IndexingMixin 7 | 8 | _IndexingMixinT = TypeVar("_IndexingMixinT", bound=IndexingMixin) 9 | 10 | class NDFrameIndexerBase(Generic[_IndexingMixinT]): 11 | name: str 12 | # in practice obj is either a DataFrame or a Series 13 | obj: _IndexingMixinT 14 | 15 | def __init__(self, name: str, obj: _IndexingMixinT) -> None: ... 16 | @property 17 | def ndim(self) -> int: ... 18 | -------------------------------------------------------------------------------- /pandas/_libs/indexing.pyx: -------------------------------------------------------------------------------- 1 | cdef class NDFrameIndexerBase: 2 | """ 3 | A base class for _NDFrameIndexer for fast instantiation and attribute access. 4 | """ 5 | cdef: 6 | Py_ssize_t _ndim 7 | 8 | cdef public: 9 | str name 10 | object obj 11 | 12 | def __init__(self, name: str, obj): 13 | self.obj = obj 14 | self.name = name 15 | self._ndim = -1 16 | 17 | @property 18 | def ndim(self) -> int: 19 | # Delay `ndim` instantiation until required as reading it 20 | # from `obj` isn't entirely cheap. 21 | ndim = self._ndim 22 | if ndim == -1: 23 | ndim = self._ndim = self.obj.ndim 24 | if ndim > 2: 25 | raise ValueError( # pragma: no cover 26 | "NDFrameIndexer does not support NDFrame objects with ndim > 2" 27 | ) 28 | return ndim 29 | -------------------------------------------------------------------------------- /pandas/_libs/json.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from typing import ( 3 | Any, 4 | ) 5 | 6 | def ujson_dumps( 7 | obj: Any, 8 | ensure_ascii: bool = ..., 9 | double_precision: int = ..., 10 | indent: int = ..., 11 | orient: str = ..., 12 | date_unit: str = ..., 13 | iso_dates: bool = ..., 14 | default_handler: None 15 | | Callable[[Any], str | float | bool | list | dict | None] = ..., 16 | ) -> str: ... 17 | def ujson_loads( 18 | s: str, 19 | precise_float: bool = ..., 20 | numpy: bool = ..., 21 | dtype: None = ..., 22 | labelled: bool = ..., 23 | ) -> Any: ... 24 | -------------------------------------------------------------------------------- /pandas/_libs/lib.pxd: -------------------------------------------------------------------------------- 1 | from numpy cimport ndarray 2 | 3 | 4 | cdef bint c_is_list_like(object, bint) except -1 5 | 6 | cpdef ndarray eq_NA_compat(ndarray[object] arr, object key) 7 | -------------------------------------------------------------------------------- /pandas/_libs/missing.pxd: -------------------------------------------------------------------------------- 1 | from numpy cimport ( 2 | ndarray, 3 | uint8_t, 4 | ) 5 | 6 | 7 | cpdef bint is_matching_na(object left, object right, bint nan_matches_none=*) 8 | cpdef bint check_na_tuples_nonequal(object left, object right) 9 | 10 | cpdef bint checknull(object val) 11 | cpdef ndarray[uint8_t] isnaobj(ndarray arr) 12 | 13 | cdef bint is_null_datetime64(v) 14 | cdef bint is_null_timedelta64(v) 15 | cdef bint checknull_with_nat_and_na(object obj) 16 | 17 | cdef class C_NAType: 18 | pass 19 | 20 | cdef C_NAType C_NA 21 | -------------------------------------------------------------------------------- /pandas/_libs/missing.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy import typing as npt 3 | 4 | class NAType: 5 | def __new__(cls, *args, **kwargs): ... 6 | 7 | NA: NAType 8 | 9 | def is_matching_na( 10 | left: object, right: object, nan_matches_none: bool = ... 11 | ) -> bool: ... 12 | def isposinf_scalar(val: object) -> bool: ... 13 | def isneginf_scalar(val: object) -> bool: ... 14 | def checknull(val: object) -> bool: ... 15 | def isnaobj(arr: np.ndarray) -> npt.NDArray[np.bool_]: ... 16 | def is_numeric_na(values: np.ndarray) -> npt.NDArray[np.bool_]: ... 17 | -------------------------------------------------------------------------------- /pandas/_libs/ops_dispatch.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def maybe_dispatch_ufunc_to_dunder_op( 4 | self, ufunc: np.ufunc, method: str, *inputs, **kwargs 5 | ): ... 6 | -------------------------------------------------------------------------------- /pandas/_libs/properties.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Sequence 2 | from typing import ( 3 | overload, 4 | ) 5 | 6 | from pandas._typing import ( 7 | AnyArrayLike, 8 | DataFrame, 9 | Index, 10 | Series, 11 | ) 12 | 13 | # note: this is a lie to make type checkers happy (they special 14 | # case property). cache_readonly uses attribute names similar to 15 | # property (fget) but it does not provide fset and fdel. 16 | cache_readonly = property 17 | 18 | class AxisProperty: 19 | axis: int 20 | def __init__(self, axis: int = ..., doc: str = ...) -> None: ... 21 | @overload 22 | def __get__(self, obj: DataFrame | Series, type) -> Index: ... 23 | @overload 24 | def __get__(self, obj: None, type) -> AxisProperty: ... 25 | def __set__( 26 | self, obj: DataFrame | Series, value: AnyArrayLike | Sequence 27 | ) -> None: ... 28 | -------------------------------------------------------------------------------- /pandas/_libs/reshape.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import npt 4 | 5 | def unstack( 6 | values: np.ndarray, # reshape_t[:, :] 7 | mask: np.ndarray, # const uint8_t[:] 8 | stride: int, 9 | length: int, 10 | width: int, 11 | new_values: np.ndarray, # reshape_t[:, :] 12 | new_mask: np.ndarray, # uint8_t[:, :] 13 | ) -> None: ... 14 | def explode( 15 | values: npt.NDArray[np.object_], 16 | ) -> tuple[npt.NDArray[np.object_], npt.NDArray[np.int64]]: ... 17 | -------------------------------------------------------------------------------- /pandas/_libs/sas.pyi: -------------------------------------------------------------------------------- 1 | from pandas.io.sas.sas7bdat import SAS7BDATReader 2 | 3 | class Parser: 4 | def __init__(self, parser: SAS7BDATReader) -> None: ... 5 | def read(self, nrows: int) -> None: ... 6 | 7 | def get_subheader_index(signature: bytes) -> int: ... 8 | -------------------------------------------------------------------------------- /pandas/_libs/testing.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping 2 | 3 | def assert_dict_equal(a: Mapping, b: Mapping, compare_keys: bool = ...) -> bool: ... 4 | def assert_almost_equal( 5 | a, 6 | b, 7 | rtol: float = ..., 8 | atol: float = ..., 9 | check_dtype: bool = ..., 10 | obj=..., 11 | lobj=..., 12 | robj=..., 13 | index_values=..., 14 | ) -> bool: ... 15 | -------------------------------------------------------------------------------- /pandas/_libs/tslib.pyi: -------------------------------------------------------------------------------- 1 | from datetime import tzinfo 2 | 3 | import numpy as np 4 | 5 | from pandas._typing import npt 6 | 7 | def format_array_from_datetime( 8 | values: npt.NDArray[np.int64], 9 | tz: tzinfo | None = ..., 10 | format: str | None = ..., 11 | na_rep: str | float = ..., 12 | reso: int = ..., # NPY_DATETIMEUNIT 13 | ) -> npt.NDArray[np.object_]: ... 14 | def first_non_null(values: np.ndarray) -> int: ... 15 | def array_to_datetime( 16 | values: npt.NDArray[np.object_], 17 | errors: str = ..., 18 | dayfirst: bool = ..., 19 | yearfirst: bool = ..., 20 | utc: bool = ..., 21 | creso: int = ..., 22 | unit_for_numerics: str | None = ..., 23 | ) -> tuple[np.ndarray, tzinfo | None]: ... 24 | 25 | # returned ndarray may be object dtype or datetime64[ns] 26 | 27 | def array_to_datetime_with_tz( 28 | values: npt.NDArray[np.object_], 29 | tz: tzinfo, 30 | dayfirst: bool, 31 | yearfirst: bool, 32 | creso: int, 33 | ) -> npt.NDArray[np.int64]: ... 34 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/base.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport datetime 2 | 3 | 4 | cdef class ABCTimestamp(datetime): 5 | pass 6 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/base.pyx: -------------------------------------------------------------------------------- 1 | """ 2 | We define base classes that will be inherited by Timestamp, Timedelta, etc 3 | in order to allow for fast isinstance checks without circular dependency issues. 4 | 5 | This is analogous to core.dtypes.generic. 6 | """ 7 | 8 | from cpython.datetime cimport datetime 9 | 10 | 11 | cdef class ABCTimestamp(datetime): 12 | pass 13 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/ccalendar.pxd: -------------------------------------------------------------------------------- 1 | from cython cimport Py_ssize_t 2 | from numpy cimport ( 3 | int32_t, 4 | int64_t, 5 | ) 6 | 7 | ctypedef (int32_t, int32_t, int32_t) iso_calendar_t 8 | 9 | cdef int dayofweek(int y, int m, int d) noexcept nogil 10 | cdef bint is_leapyear(int64_t year) noexcept nogil 11 | cpdef int32_t get_days_in_month(int year, Py_ssize_t month) noexcept nogil 12 | cpdef int32_t get_week_of_year(int year, int month, int day) noexcept nogil 13 | cpdef iso_calendar_t get_iso_calendar(int year, int month, int day) noexcept nogil 14 | cpdef int32_t get_day_of_year(int year, int month, int day) noexcept nogil 15 | cpdef int get_lastbday(int year, int month) noexcept nogil 16 | cpdef int get_firstbday(int year, int month) noexcept nogil 17 | 18 | cdef dict c_MONTH_NUMBERS, MONTH_TO_CAL_NUM 19 | 20 | cdef int32_t* month_offset 21 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/ccalendar.pyi: -------------------------------------------------------------------------------- 1 | DAYS: list[str] 2 | MONTH_ALIASES: dict[int, str] 3 | MONTH_NUMBERS: dict[str, int] 4 | MONTHS: list[str] 5 | int_to_weekday: dict[int, str] 6 | 7 | def get_firstbday(year: int, month: int) -> int: ... 8 | def get_lastbday(year: int, month: int) -> int: ... 9 | def get_day_of_year(year: int, month: int, day: int) -> int: ... 10 | def get_iso_calendar(year: int, month: int, day: int) -> tuple[int, int, int]: ... 11 | def get_week_of_year(year: int, month: int, day: int) -> int: ... 12 | def get_days_in_month(year: int, month: int) -> int: ... 13 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/conversion.pyi: -------------------------------------------------------------------------------- 1 | from datetime import ( 2 | datetime, 3 | tzinfo, 4 | ) 5 | 6 | import numpy as np 7 | 8 | DT64NS_DTYPE: np.dtype 9 | TD64NS_DTYPE: np.dtype 10 | 11 | def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ... 12 | def cast_from_unit_vectorized( 13 | values: np.ndarray, unit: str, out_unit: str = ... 14 | ) -> np.ndarray: ... 15 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/nattype.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport datetime 2 | from numpy cimport int64_t 3 | 4 | 5 | cdef int64_t NPY_NAT 6 | 7 | cdef set c_nat_strings 8 | 9 | cdef class _NaT(datetime): 10 | cdef readonly: 11 | int64_t _value 12 | 13 | cdef _NaT c_NaT 14 | 15 | 16 | cdef bint checknull_with_nat(object val) 17 | cdef bint is_dt64nat(object val) 18 | cdef bint is_td64nat(object val) 19 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/np_datetime.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import npt 4 | 5 | class OutOfBoundsDatetime(ValueError): ... 6 | class OutOfBoundsTimedelta(ValueError): ... 7 | 8 | # only exposed for testing 9 | def py_get_unit_from_dtype(dtype: np.dtype): ... 10 | def py_td64_to_tdstruct(td64: int, unit: int) -> dict: ... 11 | def astype_overflowsafe( 12 | values: np.ndarray, 13 | dtype: np.dtype, 14 | copy: bool = ..., 15 | round_ok: bool = ..., 16 | is_coerce: bool = ..., 17 | ) -> np.ndarray: ... 18 | def is_unitless(dtype: np.dtype) -> bool: ... 19 | def compare_mismatched_resolutions( 20 | left: np.ndarray, right: np.ndarray, op 21 | ) -> npt.NDArray[np.bool_]: ... 22 | def add_overflowsafe( 23 | left: npt.NDArray[np.int64], 24 | right: npt.NDArray[np.int64], 25 | ) -> npt.NDArray[np.int64]: ... 26 | def get_supported_dtype(dtype: np.dtype) -> np.dtype: ... 27 | def is_supported_dtype(dtype: np.dtype) -> bool: ... 28 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/offsets.pxd: -------------------------------------------------------------------------------- 1 | from numpy cimport int64_t 2 | 3 | 4 | cpdef to_offset(object obj, bint is_period=*) 5 | cdef bint is_offset_object(object obj) 6 | cdef bint is_tick_object(object obj) 7 | 8 | cdef class BaseOffset: 9 | cdef readonly: 10 | int64_t n 11 | bint normalize 12 | dict _cache 13 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/parsing.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport datetime 2 | from numpy cimport int64_t 3 | 4 | from pandas._libs.tslibs.np_datetime cimport NPY_DATETIMEUNIT 5 | 6 | 7 | cpdef str get_rule_month(str source) 8 | cpdef quarter_to_myear(int year, int quarter, str freq) 9 | 10 | cdef datetime parse_datetime_string( 11 | str date_string, 12 | bint dayfirst, 13 | bint yearfirst, 14 | NPY_DATETIMEUNIT* out_bestunit, 15 | int64_t* nanos, 16 | ) 17 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/parsing.pyi: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | import numpy as np 4 | 5 | from pandas._typing import npt 6 | 7 | class DateParseError(ValueError): ... 8 | 9 | def py_parse_datetime_string( 10 | date_string: str, 11 | dayfirst: bool = ..., 12 | yearfirst: bool = ..., 13 | ) -> datetime: ... 14 | def parse_datetime_string_with_reso( 15 | date_string: str, 16 | freq: str | None = ..., 17 | dayfirst: bool | None = ..., 18 | yearfirst: bool | None = ..., 19 | ) -> tuple[datetime, str]: ... 20 | def _does_string_look_like_datetime(py_string: str) -> bool: ... 21 | def quarter_to_myear(year: int, quarter: int, freq: str) -> tuple[int, int]: ... 22 | def try_parse_dates( 23 | values: npt.NDArray[np.object_], # object[:] 24 | parser, 25 | ) -> npt.NDArray[np.object_]: ... 26 | def guess_datetime_format( 27 | dt_str: str, 28 | dayfirst: bool | None = ..., 29 | ) -> str | None: ... 30 | def get_rule_month(source: str) -> str: ... 31 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/period.pxd: -------------------------------------------------------------------------------- 1 | from numpy cimport int64_t 2 | 3 | from .np_datetime cimport npy_datetimestruct 4 | 5 | 6 | cdef bint is_period_object(object obj) 7 | cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq) noexcept nogil 8 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/strptime.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport ( 2 | datetime, 3 | tzinfo, 4 | ) 5 | from numpy cimport int64_t 6 | 7 | from pandas._libs.tslibs.np_datetime cimport NPY_DATETIMEUNIT 8 | 9 | 10 | cdef bint parse_today_now( 11 | str val, int64_t* iresult, bint utc, NPY_DATETIMEUNIT creso, bint infer_reso=* 12 | ) 13 | 14 | 15 | cdef class DatetimeParseState: 16 | cdef: 17 | # See comments describing these attributes in the __cinit__ method 18 | bint found_tz 19 | bint found_naive 20 | bint found_naive_str 21 | bint found_aware_str 22 | bint found_other 23 | bint creso_ever_changed 24 | NPY_DATETIMEUNIT creso 25 | set out_tzoffset_vals 26 | 27 | cdef tzinfo process_datetime(self, datetime dt, tzinfo tz, bint utc_convert) 28 | cdef bint update_creso(self, NPY_DATETIMEUNIT item_reso) noexcept 29 | cdef tzinfo check_for_mixed_inputs(self, tzinfo tz_out, bint utc) 30 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/strptime.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import npt 4 | 5 | def array_strptime( 6 | values: npt.NDArray[np.object_], 7 | fmt: str | None, 8 | exact: bool = ..., 9 | errors: str = ..., 10 | utc: bool = ..., 11 | creso: int = ..., # NPY_DATETIMEUNIT 12 | ) -> tuple[np.ndarray, np.ndarray]: ... 13 | 14 | # first ndarray is M8[ns], second is object ndarray of tzinfo | None 15 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/timedeltas.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport timedelta 2 | from numpy cimport int64_t 3 | 4 | from .np_datetime cimport NPY_DATETIMEUNIT 5 | 6 | 7 | cpdef int64_t get_unit_for_round(freq, NPY_DATETIMEUNIT creso) except? -1 8 | # Exposed for tslib, not intended for outside use. 9 | cpdef int64_t delta_to_nanoseconds( 10 | delta, NPY_DATETIMEUNIT reso=*, bint round_ok=* 11 | ) except? -1 12 | cdef convert_to_timedelta64(object ts, str unit) 13 | cdef bint is_any_td_scalar(object obj) 14 | 15 | 16 | cdef class _Timedelta(timedelta): 17 | cdef readonly: 18 | int64_t _value # nanoseconds 19 | bint _is_populated # are my components populated 20 | int64_t _d, _h, _m, _s, _ms, _us, _ns 21 | NPY_DATETIMEUNIT _creso 22 | 23 | cpdef timedelta to_pytimedelta(_Timedelta self) 24 | cdef bint _has_ns(self) 25 | cdef bint _is_in_pytimedelta_bounds(self) 26 | cdef _ensure_components(_Timedelta self) 27 | cdef bint _compare_mismatched_resos(self, _Timedelta other, op) 28 | cdef _Timedelta _as_creso(self, NPY_DATETIMEUNIT reso, bint round_ok=*) 29 | cpdef _maybe_cast_to_matching_resos(self, _Timedelta other) 30 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/timezones.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport ( 2 | datetime, 3 | timedelta, 4 | tzinfo, 5 | ) 6 | 7 | 8 | cdef tzinfo utc_stdlib 9 | 10 | cpdef bint is_utc(tzinfo tz) 11 | cdef bint is_tzlocal(tzinfo tz) 12 | cdef bint is_zoneinfo(tzinfo tz) 13 | 14 | cdef bint treat_tz_as_pytz(tzinfo tz) 15 | 16 | cpdef bint tz_compare(tzinfo start, tzinfo end) 17 | cpdef object get_timezone(tzinfo tz) 18 | cpdef tzinfo maybe_get_tz(object tz) 19 | 20 | cdef timedelta get_utcoffset(tzinfo tz, datetime obj) 21 | cpdef bint is_fixed_offset(tzinfo tz) 22 | 23 | cdef object get_dst_info(tzinfo tz) 24 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/timezones.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Callable 2 | from datetime import ( 3 | datetime, 4 | tzinfo, 5 | ) 6 | 7 | import numpy as np 8 | 9 | # imported from dateutil.tz 10 | dateutil_gettz: Callable[[str], tzinfo] 11 | 12 | def tz_standardize(tz: tzinfo) -> tzinfo: ... 13 | def tz_compare(start: tzinfo | None, end: tzinfo | None) -> bool: ... 14 | def infer_tzinfo( 15 | start: datetime | None, 16 | end: datetime | None, 17 | ) -> tzinfo | None: ... 18 | def maybe_get_tz(tz: str | int | np.int64 | tzinfo | None) -> tzinfo | None: ... 19 | def get_timezone(tz: tzinfo) -> tzinfo | str: ... 20 | def is_utc(tz: tzinfo | None) -> bool: ... 21 | def is_fixed_offset(tz: tzinfo) -> bool: ... 22 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/tzconversion.pxd: -------------------------------------------------------------------------------- 1 | from cpython.datetime cimport tzinfo 2 | from numpy cimport ( 3 | int64_t, 4 | intp_t, 5 | ndarray, 6 | ) 7 | 8 | from pandas._libs.tslibs.np_datetime cimport NPY_DATETIMEUNIT 9 | 10 | 11 | cpdef int64_t tz_convert_from_utc_single( 12 | int64_t utc_val, tzinfo tz, NPY_DATETIMEUNIT creso=* 13 | ) except? -1 14 | cdef int64_t tz_localize_to_utc_single( 15 | int64_t val, 16 | tzinfo tz, 17 | object ambiguous=*, 18 | object nonexistent=*, 19 | NPY_DATETIMEUNIT creso=*, 20 | ) except? -1 21 | 22 | 23 | cdef class Localizer: 24 | cdef: 25 | tzinfo tz 26 | NPY_DATETIMEUNIT _creso 27 | bint use_utc, use_fixed, use_tzlocal, use_dst, use_pytz 28 | ndarray trans 29 | Py_ssize_t ntrans 30 | const int64_t[::1] deltas 31 | int64_t delta 32 | int64_t* tdata 33 | 34 | cdef int64_t utc_val_to_local_val( 35 | self, 36 | int64_t utc_val, 37 | Py_ssize_t* pos, 38 | bint* fold=?, 39 | ) except? -1 40 | -------------------------------------------------------------------------------- /pandas/_libs/tslibs/tzconversion.pyi: -------------------------------------------------------------------------------- 1 | from collections.abc import Iterable 2 | from datetime import ( 3 | timedelta, 4 | tzinfo, 5 | ) 6 | 7 | import numpy as np 8 | 9 | from pandas._typing import npt 10 | 11 | # tz_convert_from_utc_single exposed for testing 12 | def tz_convert_from_utc_single( 13 | utc_val: np.int64, tz: tzinfo, creso: int = ... 14 | ) -> np.int64: ... 15 | def tz_localize_to_utc( 16 | vals: npt.NDArray[np.int64], 17 | tz: tzinfo | None, 18 | ambiguous: str | bool | Iterable[bool] | None = ..., 19 | nonexistent: str | timedelta | np.timedelta64 | None = ..., 20 | creso: int = ..., # NPY_DATETIMEUNIT 21 | ) -> npt.NDArray[np.int64]: ... 22 | -------------------------------------------------------------------------------- /pandas/_libs/util.pxd: -------------------------------------------------------------------------------- 1 | cimport numpy as cnp 2 | from libc.stdint cimport ( 3 | INT8_MAX, 4 | INT8_MIN, 5 | INT16_MAX, 6 | INT16_MIN, 7 | INT32_MAX, 8 | INT32_MIN, 9 | INT64_MAX, 10 | INT64_MIN, 11 | UINT8_MAX, 12 | UINT16_MAX, 13 | UINT32_MAX, 14 | UINT64_MAX, 15 | ) 16 | 17 | from pandas._libs.tslibs.util cimport * 18 | -------------------------------------------------------------------------------- /pandas/_libs/window/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/_libs/window/__init__.py -------------------------------------------------------------------------------- /pandas/_libs/window/indexers.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import npt 4 | 5 | def calculate_variable_window_bounds( 6 | num_values: int, # int64_t 7 | window_size: int, # int64_t 8 | min_periods, 9 | center: bool, 10 | closed: str | None, 11 | index: np.ndarray, # const int64_t[:] 12 | ) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]]: ... 13 | -------------------------------------------------------------------------------- /pandas/_libs/window/meson.build: -------------------------------------------------------------------------------- 1 | cy_args = ['-X always_allow_keywords=true'] 2 | # Use shared utility code to reduce wheel sizes 3 | # copied from https://github.com/scikit-learn/scikit-learn/pull/31151/files 4 | if cy.version().version_compare('>=3.1.0') 5 | cython_args += ['--shared=pandas._libs._cyutility'] 6 | endif 7 | 8 | py.extension_module( 9 | 'aggregations', 10 | ['aggregations.pyx'], 11 | cython_args: cy_args, 12 | include_directories: [inc_np, inc_pd], 13 | subdir: 'pandas/_libs/window', 14 | override_options: ['cython_language=cpp'], 15 | install: true, 16 | ) 17 | 18 | py.extension_module( 19 | 'indexers', 20 | ['indexers.pyx'], 21 | cython_args: cy_args, 22 | include_directories: [inc_np, inc_pd], 23 | subdir: 'pandas/_libs/window', 24 | install: true, 25 | ) 26 | 27 | sources_to_install = ['__init__.py', 'aggregations.pyi', 'indexers.pyi'] 28 | 29 | foreach source : sources_to_install 30 | py.install_sources(source, subdir: 'pandas/_libs/window') 31 | endforeach 32 | -------------------------------------------------------------------------------- /pandas/_libs/writers.pyi: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._typing import ArrayLike 4 | 5 | def write_csv_rows( 6 | data: list[ArrayLike], 7 | data_index: np.ndarray, 8 | nlevels: int, 9 | cols: np.ndarray, 10 | writer: object, # _csv.writer 11 | ) -> None: ... 12 | def convert_json_to_lines(arr: str) -> str: ... 13 | def max_len_string_array( 14 | arr: np.ndarray, # pandas_string[:] 15 | ) -> int: ... 16 | def word_len(val: object) -> int: ... 17 | def string_array_replace_from_nan_rep( 18 | arr: np.ndarray, # np.ndarray[object, ndim=1] 19 | nan_rep: object, 20 | ) -> None: ... 21 | -------------------------------------------------------------------------------- /pandas/_testing/compat.py: -------------------------------------------------------------------------------- 1 | """ 2 | Helpers for sharing tests between DataFrame/Series 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from typing import TYPE_CHECKING 8 | 9 | from pandas import DataFrame 10 | 11 | if TYPE_CHECKING: 12 | from pandas._typing import DtypeObj 13 | 14 | 15 | def get_dtype(obj) -> DtypeObj: 16 | if isinstance(obj, DataFrame): 17 | # Note: we are assuming only one column 18 | return obj.dtypes.iat[0] 19 | else: 20 | return obj.dtype 21 | 22 | 23 | def get_obj(df: DataFrame, klass): 24 | """ 25 | For sharing tests using frame_or_series, either return the DataFrame 26 | unchanged or return it's first column as a Series. 27 | """ 28 | if klass is DataFrame: 29 | return df 30 | return df._ixs(0, axis=1) 31 | -------------------------------------------------------------------------------- /pandas/api/__init__.py: -------------------------------------------------------------------------------- 1 | """public toolkit API""" 2 | 3 | from pandas.api import ( 4 | executors, 5 | extensions, 6 | indexers, 7 | interchange, 8 | types, 9 | typing, 10 | ) 11 | 12 | __all__ = [ 13 | "executors", 14 | "extensions", 15 | "indexers", 16 | "interchange", 17 | "types", 18 | "typing", 19 | ] 20 | -------------------------------------------------------------------------------- /pandas/api/executors/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public API for function executor engines to be used with ``map`` and ``apply``. 3 | """ 4 | 5 | from pandas.core.apply import BaseExecutionEngine 6 | 7 | __all__ = ["BaseExecutionEngine"] 8 | -------------------------------------------------------------------------------- /pandas/api/extensions/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public API for extending pandas objects. 3 | """ 4 | 5 | from pandas._libs.lib import no_default 6 | 7 | from pandas.core.dtypes.base import ( 8 | ExtensionDtype, 9 | register_extension_dtype, 10 | ) 11 | 12 | from pandas.core.accessor import ( 13 | register_dataframe_accessor, 14 | register_index_accessor, 15 | register_series_accessor, 16 | ) 17 | from pandas.core.algorithms import take 18 | from pandas.core.arrays import ( 19 | ExtensionArray, 20 | ExtensionScalarOpsMixin, 21 | ) 22 | 23 | __all__ = [ 24 | "ExtensionArray", 25 | "ExtensionDtype", 26 | "ExtensionScalarOpsMixin", 27 | "no_default", 28 | "register_dataframe_accessor", 29 | "register_extension_dtype", 30 | "register_index_accessor", 31 | "register_series_accessor", 32 | "take", 33 | ] 34 | -------------------------------------------------------------------------------- /pandas/api/indexers/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public API for Rolling Window Indexers. 3 | """ 4 | 5 | from pandas.core.indexers import check_array_indexer 6 | from pandas.core.indexers.objects import ( 7 | BaseIndexer, 8 | FixedForwardWindowIndexer, 9 | VariableOffsetWindowIndexer, 10 | ) 11 | 12 | __all__ = [ 13 | "BaseIndexer", 14 | "FixedForwardWindowIndexer", 15 | "VariableOffsetWindowIndexer", 16 | "check_array_indexer", 17 | ] 18 | -------------------------------------------------------------------------------- /pandas/api/interchange/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public API for DataFrame interchange protocol. 3 | """ 4 | 5 | from pandas.core.interchange.dataframe_protocol import DataFrame 6 | from pandas.core.interchange.from_dataframe import from_dataframe 7 | 8 | __all__ = ["DataFrame", "from_dataframe"] 9 | -------------------------------------------------------------------------------- /pandas/api/types/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public toolkit API. 3 | """ 4 | 5 | from pandas._libs.lib import infer_dtype 6 | 7 | from pandas.core.dtypes.api import * # noqa: F403 8 | from pandas.core.dtypes.concat import union_categoricals 9 | from pandas.core.dtypes.dtypes import ( 10 | CategoricalDtype, 11 | DatetimeTZDtype, 12 | IntervalDtype, 13 | PeriodDtype, 14 | ) 15 | 16 | __all__ = [ 17 | "CategoricalDtype", 18 | "DatetimeTZDtype", 19 | "IntervalDtype", 20 | "PeriodDtype", 21 | "infer_dtype", 22 | "union_categoricals", 23 | ] 24 | -------------------------------------------------------------------------------- /pandas/arrays/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | All of pandas' ExtensionArrays. 3 | 4 | See :ref:`extending.extension-types` for more. 5 | """ 6 | 7 | from pandas.core.arrays import ( 8 | ArrowExtensionArray, 9 | ArrowStringArray, 10 | BooleanArray, 11 | Categorical, 12 | DatetimeArray, 13 | FloatingArray, 14 | IntegerArray, 15 | IntervalArray, 16 | NumpyExtensionArray, 17 | PeriodArray, 18 | SparseArray, 19 | StringArray, 20 | TimedeltaArray, 21 | ) 22 | 23 | __all__ = [ 24 | "ArrowExtensionArray", 25 | "ArrowStringArray", 26 | "BooleanArray", 27 | "Categorical", 28 | "DatetimeArray", 29 | "FloatingArray", 30 | "IntegerArray", 31 | "IntervalArray", 32 | "NumpyExtensionArray", 33 | "PeriodArray", 34 | "SparseArray", 35 | "StringArray", 36 | "TimedeltaArray", 37 | ] 38 | -------------------------------------------------------------------------------- /pandas/compat/_constants.py: -------------------------------------------------------------------------------- 1 | """ 2 | _constants 3 | ====== 4 | 5 | Constants relevant for the Python implementation. 6 | """ 7 | 8 | from __future__ import annotations 9 | 10 | import platform 11 | import sys 12 | import sysconfig 13 | 14 | IS64 = sys.maxsize > 2**32 15 | 16 | PY311 = sys.version_info >= (3, 11) 17 | PY312 = sys.version_info >= (3, 12) 18 | PYPY = platform.python_implementation() == "PyPy" 19 | WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]) 20 | ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "") 21 | REF_COUNT = 2 if PY311 else 3 22 | 23 | __all__ = [ 24 | "IS64", 25 | "ISMUSL", 26 | "PY311", 27 | "PY312", 28 | "PYPY", 29 | "WASM", 30 | ] 31 | -------------------------------------------------------------------------------- /pandas/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/__init__.py -------------------------------------------------------------------------------- /pandas/core/_numba/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/_numba/__init__.py -------------------------------------------------------------------------------- /pandas/core/_numba/kernels/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core._numba.kernels.mean_ import ( 2 | grouped_mean, 3 | sliding_mean, 4 | ) 5 | from pandas.core._numba.kernels.min_max_ import ( 6 | grouped_min_max, 7 | sliding_min_max, 8 | ) 9 | from pandas.core._numba.kernels.sum_ import ( 10 | grouped_sum, 11 | sliding_sum, 12 | ) 13 | from pandas.core._numba.kernels.var_ import ( 14 | grouped_var, 15 | sliding_var, 16 | ) 17 | 18 | __all__ = [ 19 | "grouped_mean", 20 | "grouped_min_max", 21 | "grouped_sum", 22 | "grouped_var", 23 | "sliding_mean", 24 | "sliding_min_max", 25 | "sliding_sum", 26 | "sliding_var", 27 | ] 28 | -------------------------------------------------------------------------------- /pandas/core/_numba/kernels/shared.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TYPE_CHECKING 4 | 5 | import numba 6 | 7 | if TYPE_CHECKING: 8 | import numpy as np 9 | 10 | 11 | @numba.jit( 12 | # error: Any? not callable 13 | numba.boolean(numba.int64[:]), # type: ignore[misc] 14 | nopython=True, 15 | nogil=True, 16 | parallel=False, 17 | ) 18 | def is_monotonic_increasing(bounds: np.ndarray) -> bool: 19 | """Check if int64 values are monotonically increasing.""" 20 | n = len(bounds) 21 | if n < 2: 22 | return True 23 | prev = bounds[0] 24 | for i in range(1, n): 25 | cur = bounds[i] 26 | if cur < prev: 27 | return False 28 | prev = cur 29 | return True 30 | -------------------------------------------------------------------------------- /pandas/core/array_algos/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | core.array_algos is for algorithms that operate on ndarray and ExtensionArray. 3 | These should: 4 | 5 | - Assume that any Index, Series, or DataFrame objects have already been unwrapped. 6 | - Assume that any list arguments have already been cast to ndarray/EA. 7 | - Not depend on Index, Series, or DataFrame, nor import any of these. 8 | - May dispatch to ExtensionArray methods, but should not import from core.arrays. 9 | """ 10 | -------------------------------------------------------------------------------- /pandas/core/array_algos/transforms.py: -------------------------------------------------------------------------------- 1 | """ 2 | transforms.py is for shape-preserving functions. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from typing import TYPE_CHECKING 8 | 9 | import numpy as np 10 | 11 | if TYPE_CHECKING: 12 | from pandas._typing import ( 13 | AxisInt, 14 | Scalar, 15 | ) 16 | 17 | 18 | def shift( 19 | values: np.ndarray, periods: int, axis: AxisInt, fill_value: Scalar 20 | ) -> np.ndarray: 21 | new_values = values 22 | 23 | if periods == 0 or values.size == 0: 24 | return new_values.copy() 25 | 26 | # make sure array sent to np.roll is c_contiguous 27 | f_ordered = values.flags.f_contiguous 28 | if f_ordered: 29 | new_values = new_values.T 30 | axis = new_values.ndim - axis - 1 31 | 32 | if new_values.size: 33 | new_values = np.roll( 34 | new_values, 35 | np.intp(periods), 36 | axis=axis, 37 | ) 38 | 39 | axis_indexer = [slice(None)] * values.ndim 40 | if periods > 0: 41 | axis_indexer[axis] = slice(None, periods) 42 | else: 43 | axis_indexer[axis] = slice(periods, None) 44 | new_values[tuple(axis_indexer)] = fill_value 45 | 46 | # restore original order 47 | if f_ordered: 48 | new_values = new_values.T 49 | 50 | return new_values 51 | -------------------------------------------------------------------------------- /pandas/core/arrays/arrow/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core.arrays.arrow.accessors import ( 2 | ListAccessor, 3 | StructAccessor, 4 | ) 5 | from pandas.core.arrays.arrow.array import ArrowExtensionArray 6 | 7 | __all__ = ["ArrowExtensionArray", "ListAccessor", "StructAccessor"] 8 | -------------------------------------------------------------------------------- /pandas/core/arrays/sparse/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core.arrays.sparse.accessor import ( 2 | SparseAccessor, 3 | SparseFrameAccessor, 4 | ) 5 | from pandas.core.arrays.sparse.array import ( 6 | BlockIndex, 7 | IntIndex, 8 | SparseArray, 9 | make_sparse_index, 10 | ) 11 | 12 | __all__ = [ 13 | "BlockIndex", 14 | "IntIndex", 15 | "SparseAccessor", 16 | "SparseArray", 17 | "SparseFrameAccessor", 18 | "make_sparse_index", 19 | ] 20 | -------------------------------------------------------------------------------- /pandas/core/computation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/computation/__init__.py -------------------------------------------------------------------------------- /pandas/core/computation/api.py: -------------------------------------------------------------------------------- 1 | __all__ = ["eval"] 2 | from pandas.core.computation.eval import eval 3 | -------------------------------------------------------------------------------- /pandas/core/computation/check.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from pandas.compat._optional import import_optional_dependency 4 | 5 | ne = import_optional_dependency("numexpr", errors="warn") 6 | NUMEXPR_INSTALLED = ne is not None 7 | 8 | __all__ = ["NUMEXPR_INSTALLED"] 9 | -------------------------------------------------------------------------------- /pandas/core/dtypes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/dtypes/__init__.py -------------------------------------------------------------------------------- /pandas/core/groupby/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core.groupby.generic import ( 2 | DataFrameGroupBy, 3 | NamedAgg, 4 | SeriesGroupBy, 5 | ) 6 | from pandas.core.groupby.groupby import GroupBy 7 | from pandas.core.groupby.grouper import Grouper 8 | 9 | __all__ = [ 10 | "DataFrameGroupBy", 11 | "GroupBy", 12 | "Grouper", 13 | "NamedAgg", 14 | "SeriesGroupBy", 15 | ] 16 | -------------------------------------------------------------------------------- /pandas/core/indexers/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core.indexers.utils import ( 2 | check_array_indexer, 3 | check_key_length, 4 | check_setitem_lengths, 5 | disallow_ndim_indexing, 6 | is_empty_indexer, 7 | is_list_like_indexer, 8 | is_scalar_indexer, 9 | is_valid_positional_slice, 10 | length_of_indexer, 11 | maybe_convert_indices, 12 | unpack_1tuple, 13 | unpack_tuple_and_ellipses, 14 | validate_indices, 15 | ) 16 | 17 | __all__ = [ 18 | "check_array_indexer", 19 | "check_key_length", 20 | "check_setitem_lengths", 21 | "disallow_ndim_indexing", 22 | "is_empty_indexer", 23 | "is_list_like_indexer", 24 | "is_scalar_indexer", 25 | "is_valid_positional_slice", 26 | "length_of_indexer", 27 | "maybe_convert_indices", 28 | "unpack_1tuple", 29 | "unpack_tuple_and_ellipses", 30 | "validate_indices", 31 | ] 32 | -------------------------------------------------------------------------------- /pandas/core/indexes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/indexes/__init__.py -------------------------------------------------------------------------------- /pandas/core/interchange/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/interchange/__init__.py -------------------------------------------------------------------------------- /pandas/core/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/methods/__init__.py -------------------------------------------------------------------------------- /pandas/core/ops/dispatch.py: -------------------------------------------------------------------------------- 1 | """ 2 | Functions for defining unary operations. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Any, 10 | ) 11 | 12 | from pandas.core.dtypes.generic import ABCExtensionArray 13 | 14 | if TYPE_CHECKING: 15 | from pandas._typing import ArrayLike 16 | 17 | 18 | def should_extension_dispatch(left: ArrayLike, right: Any) -> bool: 19 | """ 20 | Identify cases where Series operation should dispatch to ExtensionArray method. 21 | 22 | Parameters 23 | ---------- 24 | left : np.ndarray or ExtensionArray 25 | right : object 26 | 27 | Returns 28 | ------- 29 | bool 30 | """ 31 | return isinstance(left, ABCExtensionArray) or isinstance(right, ABCExtensionArray) 32 | -------------------------------------------------------------------------------- /pandas/core/reshape/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/reshape/__init__.py -------------------------------------------------------------------------------- /pandas/core/reshape/api.py: -------------------------------------------------------------------------------- 1 | from pandas.core.reshape.concat import concat 2 | from pandas.core.reshape.encoding import ( 3 | from_dummies, 4 | get_dummies, 5 | ) 6 | from pandas.core.reshape.melt import ( 7 | lreshape, 8 | melt, 9 | wide_to_long, 10 | ) 11 | from pandas.core.reshape.merge import ( 12 | merge, 13 | merge_asof, 14 | merge_ordered, 15 | ) 16 | from pandas.core.reshape.pivot import ( 17 | crosstab, 18 | pivot, 19 | pivot_table, 20 | ) 21 | from pandas.core.reshape.tile import ( 22 | cut, 23 | qcut, 24 | ) 25 | 26 | __all__ = [ 27 | "concat", 28 | "crosstab", 29 | "cut", 30 | "from_dummies", 31 | "get_dummies", 32 | "lreshape", 33 | "melt", 34 | "merge", 35 | "merge_asof", 36 | "merge_ordered", 37 | "pivot", 38 | "pivot_table", 39 | "qcut", 40 | "wide_to_long", 41 | ] 42 | -------------------------------------------------------------------------------- /pandas/core/sparse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/sparse/__init__.py -------------------------------------------------------------------------------- /pandas/core/sparse/api.py: -------------------------------------------------------------------------------- 1 | from pandas.core.dtypes.dtypes import SparseDtype 2 | 3 | from pandas.core.arrays.sparse import SparseArray 4 | 5 | __all__ = ["SparseArray", "SparseDtype"] 6 | -------------------------------------------------------------------------------- /pandas/core/strings/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Implementation of pandas.Series.str and its interface. 3 | 4 | * strings.accessor.StringMethods : Accessor for Series.str 5 | * strings.base.BaseStringArrayMethods: Mixin ABC for EAs to implement str methods 6 | 7 | Most methods on the StringMethods accessor follow the pattern: 8 | 9 | 1. extract the array from the series (or index) 10 | 2. Call that array's implementation of the string method 11 | 3. Wrap the result (in a Series, index, or DataFrame) 12 | 13 | Pandas extension arrays implementing string methods should inherit from 14 | pandas.core.strings.base.BaseStringArrayMethods. This is an ABC defining 15 | the various string methods. To avoid namespace clashes and pollution, 16 | these are prefixed with `_str_`. So ``Series.str.upper()`` calls 17 | ``Series.array._str_upper()``. The interface isn't currently public 18 | to other string extension arrays. 19 | """ 20 | # Pandas current implementation is in ObjectStringArrayMixin. This is designed 21 | # to work on object-dtype ndarrays. 22 | # 23 | # BaseStringArrayMethods 24 | # - ObjectStringArrayMixin 25 | # - StringArray 26 | # - NumpyExtensionArray 27 | # - Categorical 28 | # - ArrowStringArray 29 | -------------------------------------------------------------------------------- /pandas/core/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/tools/__init__.py -------------------------------------------------------------------------------- /pandas/core/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/core/util/__init__.py -------------------------------------------------------------------------------- /pandas/core/window/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.core.window.ewm import ( 2 | ExponentialMovingWindow, 3 | ExponentialMovingWindowGroupby, 4 | ) 5 | from pandas.core.window.expanding import ( 6 | Expanding, 7 | ExpandingGroupby, 8 | ) 9 | from pandas.core.window.rolling import ( 10 | Rolling, 11 | RollingGroupby, 12 | Window, 13 | ) 14 | 15 | __all__ = [ 16 | "Expanding", 17 | "ExpandingGroupby", 18 | "ExponentialMovingWindow", 19 | "ExponentialMovingWindowGroupby", 20 | "Rolling", 21 | "RollingGroupby", 22 | "Window", 23 | ] 24 | -------------------------------------------------------------------------------- /pandas/errors/cow.py: -------------------------------------------------------------------------------- 1 | _chained_assignment_msg = ( 2 | "A value is trying to be set on a copy of a DataFrame or Series " 3 | "through chained assignment.\n" 4 | "When using the Copy-on-Write mode, such chained assignment never works " 5 | "to update the original DataFrame or Series, because the intermediate " 6 | "object on which we are setting values always behaves as a copy.\n\n" 7 | "Try using '.loc[row_indexer, col_indexer] = value' instead, to perform " 8 | "the assignment in a single step.\n\n" 9 | "See the caveats in the documentation: " 10 | "https://pandas.pydata.org/pandas-docs/stable/user_guide/" 11 | "copy_on_write.html" 12 | ) 13 | 14 | 15 | _chained_assignment_method_msg = ( 16 | "A value is trying to be set on a copy of a DataFrame or Series " 17 | "through chained assignment using an inplace method.\n" 18 | "When using the Copy-on-Write mode, such inplace method never works " 19 | "to update the original DataFrame or Series, because the intermediate " 20 | "object on which we are setting values always behaves as a copy.\n\n" 21 | "For example, when doing 'df[col].method(value, inplace=True)', try " 22 | "using 'df.method({col: value}, inplace=True)' instead, to perform " 23 | "the operation inplace on the original object.\n\n" 24 | ) 25 | -------------------------------------------------------------------------------- /pandas/io/__init__.py: -------------------------------------------------------------------------------- 1 | # ruff: noqa: TC004 2 | from typing import TYPE_CHECKING 3 | 4 | if TYPE_CHECKING: 5 | # import modules that have public classes/functions 6 | from pandas.io import ( 7 | formats, 8 | json, 9 | stata, 10 | ) 11 | 12 | # mark only those modules as public 13 | __all__ = ["formats", "json", "stata"] 14 | -------------------------------------------------------------------------------- /pandas/io/excel/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.io.excel._base import ( 2 | ExcelFile, 3 | ExcelWriter, 4 | read_excel, 5 | ) 6 | from pandas.io.excel._odswriter import ODSWriter as _ODSWriter 7 | from pandas.io.excel._openpyxl import OpenpyxlWriter as _OpenpyxlWriter 8 | from pandas.io.excel._util import register_writer 9 | from pandas.io.excel._xlsxwriter import XlsxWriter as _XlsxWriter 10 | 11 | __all__ = ["ExcelFile", "ExcelWriter", "read_excel"] 12 | 13 | 14 | register_writer(_OpenpyxlWriter) 15 | 16 | register_writer(_XlsxWriter) 17 | 18 | 19 | register_writer(_ODSWriter) 20 | -------------------------------------------------------------------------------- /pandas/io/formats/__init__.py: -------------------------------------------------------------------------------- 1 | # ruff: noqa: TC004 2 | from typing import TYPE_CHECKING 3 | 4 | if TYPE_CHECKING: 5 | # import modules that have public classes/functions 6 | from pandas.io.formats import style 7 | 8 | # and mark only those modules as public 9 | __all__ = ["style"] 10 | -------------------------------------------------------------------------------- /pandas/io/formats/templates/html.tpl: -------------------------------------------------------------------------------- 1 | {# Update the html_style/table_structure.html documentation too #} 2 | {% if doctype_html %} 3 | 4 | 5 | 6 | 7 | {% if not exclude_styles %}{% include html_style_tpl %}{% endif %} 8 | 9 | 10 | {% include html_table_tpl %} 11 | 12 | 13 | {% elif not doctype_html %} 14 | {% if not exclude_styles %}{% include html_style_tpl %}{% endif %} 15 | {% include html_table_tpl %} 16 | {% endif %} 17 | -------------------------------------------------------------------------------- /pandas/io/formats/templates/html_style.tpl: -------------------------------------------------------------------------------- 1 | {%- block before_style -%}{%- endblock before_style -%} 2 | {% block style %} 3 | 26 | {% endblock style %} 27 | -------------------------------------------------------------------------------- /pandas/io/formats/templates/latex.tpl: -------------------------------------------------------------------------------- 1 | {% if environment == "longtable" %} 2 | {% include "latex_longtable.tpl" %} 3 | {% else %} 4 | {% include "latex_table.tpl" %} 5 | {% endif %} 6 | -------------------------------------------------------------------------------- /pandas/io/formats/templates/string.tpl: -------------------------------------------------------------------------------- 1 | {% for r in head %} 2 | {% for c in r %}{% if c["is_visible"] %} 3 | {{ c["display_value"] }}{% if not loop.last %}{{ delimiter }}{% endif %} 4 | {% endif %}{% endfor %} 5 | 6 | {% endfor %} 7 | {% for r in body %} 8 | {% for c in r %}{% if c["is_visible"] %} 9 | {{ c["display_value"] }}{% if not loop.last %}{{ delimiter }}{% endif %} 10 | {% endif %}{% endfor %} 11 | 12 | {% endfor %} 13 | -------------------------------------------------------------------------------- /pandas/io/formats/templates/typst.tpl: -------------------------------------------------------------------------------- 1 | #table( 2 | columns: {{ head[0] | length }}, 3 | {% for r in head %} 4 | {% for c in r %}[{% if c["is_visible"] %}{{ c["display_value"] }}{% endif %}],{% if not loop.last %} {% endif%}{% endfor %} 5 | 6 | {% endfor %} 7 | 8 | {% for r in body %} 9 | {% for c in r %}[{% if c["is_visible"] %}{{ c["display_value"] }}{% endif %}],{% if not loop.last %} {% endif%}{% endfor %} 10 | 11 | {% endfor %} 12 | ) 13 | -------------------------------------------------------------------------------- /pandas/io/json/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.io.json._json import ( 2 | read_json, 3 | to_json, 4 | ujson_dumps, 5 | ujson_loads, 6 | ) 7 | from pandas.io.json._table_schema import build_table_schema 8 | 9 | __all__ = [ 10 | "build_table_schema", 11 | "read_json", 12 | "to_json", 13 | "ujson_dumps", 14 | "ujson_loads", 15 | ] 16 | -------------------------------------------------------------------------------- /pandas/io/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.io.parsers.readers import ( 2 | TextFileReader, 3 | TextParser, 4 | read_csv, 5 | read_fwf, 6 | read_table, 7 | ) 8 | 9 | __all__ = ["TextFileReader", "TextParser", "read_csv", "read_fwf", "read_table"] 10 | -------------------------------------------------------------------------------- /pandas/io/sas/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.io.sas.sasreader import read_sas 2 | 3 | __all__ = ["read_sas"] 4 | -------------------------------------------------------------------------------- /pandas/meson.build: -------------------------------------------------------------------------------- 1 | incdir_numpy = run_command( 2 | py, 3 | [ 4 | '-c', 5 | ''' 6 | import os 7 | import numpy as np 8 | try: 9 | # Check if include directory is inside the pandas dir 10 | # e.g. a venv created inside the pandas dir 11 | # If so, convert it to a relative path 12 | incdir = os.path.relpath(np.get_include()) 13 | except Exception: 14 | incdir = np.get_include() 15 | print(incdir) 16 | ''', 17 | ], 18 | check: true, 19 | ).stdout().strip() 20 | 21 | inc_np = include_directories(incdir_numpy) 22 | inc_pd = include_directories('_libs/include') 23 | 24 | fs.copyfile('__init__.py') 25 | 26 | subdir('_libs') 27 | 28 | subdirs_list = [ 29 | '_config', 30 | '_testing', 31 | 'api', 32 | 'arrays', 33 | 'compat', 34 | 'core', 35 | 'errors', 36 | 'io', 37 | 'plotting', 38 | 'tests', 39 | 'tseries', 40 | 'util', 41 | ] 42 | foreach subdir : subdirs_list 43 | install_subdir(subdir, install_dir: py.get_install_dir() / 'pandas') 44 | endforeach 45 | 46 | top_level_py_list = [ 47 | '__init__.py', 48 | '_typing.py', 49 | '_version.py', 50 | 'conftest.py', 51 | 'testing.py', 52 | ] 53 | py.install_sources(top_level_py_list, subdir: 'pandas') 54 | -------------------------------------------------------------------------------- /pandas/testing.py: -------------------------------------------------------------------------------- 1 | """ 2 | Public testing utility functions. 3 | """ 4 | 5 | from pandas._testing import ( 6 | assert_extension_array_equal, 7 | assert_frame_equal, 8 | assert_index_equal, 9 | assert_series_equal, 10 | ) 11 | 12 | __all__ = [ 13 | "assert_extension_array_equal", 14 | "assert_frame_equal", 15 | "assert_index_equal", 16 | "assert_series_equal", 17 | ] 18 | -------------------------------------------------------------------------------- /pandas/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/__init__.py -------------------------------------------------------------------------------- /pandas/tests/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/api/__init__.py -------------------------------------------------------------------------------- /pandas/tests/apply/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/apply/__init__.py -------------------------------------------------------------------------------- /pandas/tests/apply/common.py: -------------------------------------------------------------------------------- 1 | from pandas.core.groupby.base import transformation_kernels 2 | 3 | # There is no Series.cumcount or DataFrame.cumcount 4 | series_transform_kernels = [ 5 | x for x in sorted(transformation_kernels) if x != "cumcount" 6 | ] 7 | frame_transform_kernels = [x for x in sorted(transformation_kernels) if x != "cumcount"] 8 | -------------------------------------------------------------------------------- /pandas/tests/apply/test_series_apply_relabeling.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import pandas._testing as tm 3 | 4 | 5 | def test_relabel_no_duplicated_method(): 6 | # this is to test there is no duplicated method used in agg 7 | df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4]}) 8 | 9 | result = df["A"].agg(foo="sum") 10 | expected = df["A"].agg({"foo": "sum"}) 11 | tm.assert_series_equal(result, expected) 12 | 13 | result = df["B"].agg(foo="min", bar="max") 14 | expected = df["B"].agg({"foo": "min", "bar": "max"}) 15 | tm.assert_series_equal(result, expected) 16 | 17 | result = df["B"].agg(foo=sum, bar=min, cat="max") 18 | expected = df["B"].agg({"foo": sum, "bar": min, "cat": "max"}) 19 | tm.assert_series_equal(result, expected) 20 | 21 | 22 | def test_relabel_duplicated_method(): 23 | # this is to test with nested renaming, duplicated method can be used 24 | # if they are assigned with different new names 25 | df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4]}) 26 | 27 | result = df["A"].agg(foo="sum", bar="sum") 28 | expected = pd.Series([6, 6], index=["foo", "bar"], name="A") 29 | tm.assert_series_equal(result, expected) 30 | 31 | result = df["B"].agg(foo=min, bar="min") 32 | expected = pd.Series([1, 1], index=["foo", "bar"], name="B") 33 | tm.assert_series_equal(result, expected) 34 | -------------------------------------------------------------------------------- /pandas/tests/arithmetic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arithmetic/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arithmetic/test_array_ops.py: -------------------------------------------------------------------------------- 1 | import operator 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | import pandas._testing as tm 7 | from pandas.core.ops.array_ops import ( 8 | comparison_op, 9 | na_logical_op, 10 | ) 11 | 12 | 13 | def test_na_logical_op_2d(): 14 | left = np.arange(8).reshape(4, 2) 15 | right = left.astype(object) 16 | right[0, 0] = np.nan 17 | 18 | # Check that we fall back to the vec_binop branch 19 | with pytest.raises(TypeError, match="unsupported operand type"): 20 | operator.or_(left, right) 21 | 22 | result = na_logical_op(left, right, operator.or_) 23 | expected = right 24 | tm.assert_numpy_array_equal(result, expected) 25 | 26 | 27 | def test_object_comparison_2d(): 28 | left = np.arange(9).reshape(3, 3).astype(object) 29 | right = left.T 30 | 31 | result = comparison_op(left, right, operator.eq) 32 | expected = np.eye(3).astype(bool) 33 | tm.assert_numpy_array_equal(result, expected) 34 | 35 | # Ensure that cython doesn't raise on non-writeable arg, which 36 | # we can get from np.broadcast_to 37 | right.flags.writeable = False 38 | result = comparison_op(left, right, operator.ne) 39 | tm.assert_numpy_array_equal(result, ~expected) 40 | -------------------------------------------------------------------------------- /pandas/tests/arithmetic/test_categorical.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | Categorical, 5 | Series, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestCategoricalComparisons: 11 | def test_categorical_nan_equality(self): 12 | cat = Series(Categorical(["a", "b", "c", np.nan])) 13 | expected = Series([True, True, True, False]) 14 | result = cat == cat 15 | tm.assert_series_equal(result, expected) 16 | 17 | def test_categorical_tuple_equality(self): 18 | # GH 18050 19 | ser = Series([(0, 0), (0, 1), (0, 0), (1, 0), (1, 1)]) 20 | expected = Series([True, False, True, False, False]) 21 | result = ser == (0, 0) 22 | tm.assert_series_equal(result, expected) 23 | 24 | result = ser.astype("category") == (0, 0) 25 | tm.assert_series_equal(result, expected) 26 | -------------------------------------------------------------------------------- /pandas/tests/arrays/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/boolean/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/boolean/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/boolean/test_indexing.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | import pandas as pd 5 | import pandas._testing as tm 6 | 7 | 8 | @pytest.mark.parametrize("na", [None, np.nan, pd.NA]) 9 | def test_setitem_missing_values(na): 10 | arr = pd.array([True, False, None], dtype="boolean") 11 | expected = pd.array([True, None, None], dtype="boolean") 12 | arr[1] = na 13 | tm.assert_extension_array_equal(arr, expected) 14 | -------------------------------------------------------------------------------- /pandas/tests/arrays/boolean/test_ops.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import pandas._testing as tm 3 | 4 | 5 | class TestUnaryOps: 6 | def test_invert(self): 7 | a = pd.array([True, False, None], dtype="boolean") 8 | expected = pd.array([False, True, None], dtype="boolean") 9 | tm.assert_extension_array_equal(~a, expected) 10 | 11 | expected = pd.Series(expected, index=["a", "b", "c"], name="name") 12 | result = ~pd.Series(a, index=["a", "b", "c"], name="name") 13 | tm.assert_series_equal(result, expected) 14 | 15 | df = pd.DataFrame({"A": a, "B": [True, False, False]}, index=["a", "b", "c"]) 16 | result = ~df 17 | expected = pd.DataFrame( 18 | {"A": expected, "B": [False, True, True]}, index=["a", "b", "c"] 19 | ) 20 | tm.assert_frame_equal(result, expected) 21 | 22 | def test_abs(self): 23 | # matching numpy behavior, abs is the identity function 24 | arr = pd.array([True, False, None], dtype="boolean") 25 | result = abs(arr) 26 | 27 | tm.assert_extension_array_equal(result, arr) 28 | -------------------------------------------------------------------------------- /pandas/tests/arrays/boolean/test_repr.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | 4 | def test_repr(): 5 | df = pd.DataFrame({"A": pd.array([True, False, None], dtype="boolean")}) 6 | expected = " A\n0 True\n1 False\n2 " 7 | assert repr(df) == expected 8 | 9 | expected = "0 True\n1 False\n2 \nName: A, dtype: boolean" 10 | assert repr(df.A) == expected 11 | 12 | expected = "\n[True, False, ]\nLength: 3, dtype: boolean" 13 | assert repr(df.A.array) == expected 14 | -------------------------------------------------------------------------------- /pandas/tests/arrays/categorical/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/categorical/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/categorical/test_subclass.py: -------------------------------------------------------------------------------- 1 | from pandas import Categorical 2 | import pandas._testing as tm 3 | 4 | 5 | class SubclassedCategorical(Categorical): 6 | pass 7 | 8 | 9 | class TestCategoricalSubclassing: 10 | def test_constructor(self): 11 | sc = SubclassedCategorical(["a", "b", "c"]) 12 | assert isinstance(sc, SubclassedCategorical) 13 | tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"])) 14 | 15 | def test_from_codes(self): 16 | sc = SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"]) 17 | assert isinstance(sc, SubclassedCategorical) 18 | exp = Categorical.from_codes([1, 0, 2], ["a", "b", "c"]) 19 | tm.assert_categorical_equal(sc, exp) 20 | 21 | def test_map(self): 22 | sc = SubclassedCategorical(["a", "b", "c"]) 23 | res = sc.map(lambda x: x.upper(), na_action=None) 24 | assert isinstance(res, SubclassedCategorical) 25 | exp = Categorical(["A", "B", "C"]) 26 | tm.assert_categorical_equal(res, exp) 27 | -------------------------------------------------------------------------------- /pandas/tests/arrays/categorical/test_warnings.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas._testing as tm 4 | 5 | 6 | class TestCategoricalWarnings: 7 | def test_tab_complete_warning(self, ip): 8 | # https://github.com/pandas-dev/pandas/issues/16409 9 | pytest.importorskip("IPython", minversion="6.0.0") 10 | from IPython.core.completer import provisionalcompleter 11 | 12 | code = "import pandas as pd; c = pd.Categorical([])" 13 | ip.run_cell(code) 14 | 15 | # GH 31324 newer jedi version raises Deprecation warning; 16 | # appears resolved 2021-02-02 17 | with tm.assert_produces_warning(None, raise_on_extra_warnings=False): 18 | with provisionalcompleter("ignore"): 19 | list(ip.Completer.completions("c.", 1)) 20 | -------------------------------------------------------------------------------- /pandas/tests/arrays/datetimes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/datetimes/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/floating/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/floating/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/floating/conftest.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | import pandas as pd 5 | from pandas.core.arrays.floating import ( 6 | Float32Dtype, 7 | Float64Dtype, 8 | ) 9 | 10 | 11 | @pytest.fixture(params=[Float32Dtype, Float64Dtype]) 12 | def dtype(request): 13 | """Parametrized fixture returning a float 'dtype'""" 14 | return request.param() 15 | 16 | 17 | @pytest.fixture 18 | def data(dtype): 19 | """Fixture returning 'data' array according to parametrized float 'dtype'""" 20 | return pd.array( 21 | list(np.arange(0.1, 0.9, 0.1)) 22 | + [pd.NA] 23 | + list(np.arange(1, 9.8, 0.1)) 24 | + [pd.NA] 25 | + [9.9, 10.0], 26 | dtype=dtype, 27 | ) 28 | 29 | 30 | @pytest.fixture 31 | def data_missing(dtype): 32 | """ 33 | Fixture returning array with missing data according to parametrized float 34 | 'dtype'. 35 | """ 36 | return pd.array([np.nan, 0.1], dtype=dtype) 37 | 38 | 39 | @pytest.fixture(params=["data", "data_missing"]) 40 | def all_data(request, data, data_missing): 41 | """Parametrized fixture returning 'data' or 'data_missing' float arrays. 42 | 43 | Used to test dtype conversion with and without missing values. 44 | """ 45 | if request.param == "data": 46 | return data 47 | elif request.param == "data_missing": 48 | return data_missing 49 | -------------------------------------------------------------------------------- /pandas/tests/arrays/floating/test_concat.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas as pd 4 | import pandas._testing as tm 5 | 6 | 7 | @pytest.mark.parametrize( 8 | "to_concat_dtypes, result_dtype", 9 | [ 10 | (["Float64", "Float64"], "Float64"), 11 | (["Float32", "Float64"], "Float64"), 12 | (["Float32", "Float32"], "Float32"), 13 | ], 14 | ) 15 | def test_concat_series(to_concat_dtypes, result_dtype): 16 | result = pd.concat([pd.Series([1, 2, pd.NA], dtype=t) for t in to_concat_dtypes]) 17 | expected = pd.concat([pd.Series([1, 2, pd.NA], dtype=object)] * 2).astype( 18 | result_dtype 19 | ) 20 | tm.assert_series_equal(result, expected) 21 | -------------------------------------------------------------------------------- /pandas/tests/arrays/floating/test_contains.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import pandas as pd 4 | 5 | 6 | def test_contains_nan(): 7 | # GH#52840 8 | arr = pd.array(range(5)) / 0 9 | 10 | assert np.isnan(arr._data[0]) 11 | assert not arr.isna()[0] 12 | assert np.nan in arr 13 | -------------------------------------------------------------------------------- /pandas/tests/arrays/floating/test_repr.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | import pandas as pd 5 | from pandas.core.arrays.floating import ( 6 | Float32Dtype, 7 | Float64Dtype, 8 | ) 9 | 10 | 11 | def test_dtypes(dtype): 12 | # smoke tests on auto dtype construction 13 | 14 | np.dtype(dtype.type).kind == "f" 15 | assert dtype.name is not None 16 | 17 | 18 | @pytest.mark.parametrize( 19 | "dtype, expected", 20 | [(Float32Dtype(), "Float32Dtype()"), (Float64Dtype(), "Float64Dtype()")], 21 | ) 22 | def test_repr_dtype(dtype, expected): 23 | assert repr(dtype) == expected 24 | 25 | 26 | def test_repr_array(): 27 | result = repr(pd.array([1.0, None, 3.0])) 28 | expected = "\n[1.0, , 3.0]\nLength: 3, dtype: Float64" 29 | assert result == expected 30 | 31 | 32 | def test_repr_array_long(): 33 | data = pd.array([1.0, 2.0, None] * 1000) 34 | expected = """ 35 | [ 1.0, 2.0, , 1.0, 2.0, , 1.0, 2.0, , 1.0, 36 | ... 37 | , 1.0, 2.0, , 1.0, 2.0, , 1.0, 2.0, ] 38 | Length: 3000, dtype: Float64""" 39 | result = repr(data) 40 | assert result == expected 41 | 42 | 43 | def test_frame_repr(data_missing): 44 | df = pd.DataFrame({"A": data_missing}) 45 | result = repr(df) 46 | expected = " A\n0 \n1 0.1" 47 | assert result == expected 48 | -------------------------------------------------------------------------------- /pandas/tests/arrays/integer/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/integer/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/integer/test_indexing.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import pandas._testing as tm 3 | 4 | 5 | def test_array_setitem_nullable_boolean_mask(): 6 | # GH 31446 7 | ser = pd.Series([1, 2], dtype="Int64") 8 | result = ser.where(ser > 1) 9 | expected = pd.Series([pd.NA, 2], dtype="Int64") 10 | tm.assert_series_equal(result, expected) 11 | 12 | 13 | def test_array_setitem(): 14 | # GH 31446 15 | arr = pd.Series([1, 2], dtype="Int64").array 16 | arr[arr > 1] = 1 17 | 18 | expected = pd.array([1, 1], dtype="Int64") 19 | tm.assert_extension_array_equal(arr, expected) 20 | -------------------------------------------------------------------------------- /pandas/tests/arrays/interval/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/interval/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/interval/test_astype.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | Categorical, 5 | CategoricalDtype, 6 | Index, 7 | IntervalIndex, 8 | ) 9 | import pandas._testing as tm 10 | 11 | 12 | class TestAstype: 13 | @pytest.mark.parametrize("ordered", [True, False]) 14 | def test_astype_categorical_retains_ordered(self, ordered): 15 | index = IntervalIndex.from_breaks(range(5)) 16 | arr = index._data 17 | 18 | dtype = CategoricalDtype(None, ordered=ordered) 19 | 20 | expected = Categorical(list(arr), ordered=ordered) 21 | result = arr.astype(dtype) 22 | assert result.ordered is ordered 23 | tm.assert_categorical_equal(result, expected) 24 | 25 | # test IntervalIndex.astype while we're at it. 26 | result = index.astype(dtype) 27 | expected = Index(expected) 28 | tm.assert_index_equal(result, expected) 29 | -------------------------------------------------------------------------------- /pandas/tests/arrays/interval/test_formats.py: -------------------------------------------------------------------------------- 1 | from pandas.core.arrays import IntervalArray 2 | 3 | 4 | def test_repr(): 5 | # GH#25022 6 | arr = IntervalArray.from_tuples([(0, 1), (1, 2)]) 7 | result = repr(arr) 8 | expected = ( 9 | "\n[(0, 1], (1, 2]]\nLength: 2, dtype: interval[int64, right]" 10 | ) 11 | assert result == expected 12 | -------------------------------------------------------------------------------- /pandas/tests/arrays/masked/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/masked/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/numpy_/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/numpy_/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/period/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/period/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/period/test_reductions.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pandas.core.arrays import period_array 3 | 4 | 5 | class TestReductions: 6 | def test_min_max(self): 7 | arr = period_array( 8 | [ 9 | "2000-01-03", 10 | "2000-01-03", 11 | "NaT", 12 | "2000-01-02", 13 | "2000-01-05", 14 | "2000-01-04", 15 | ], 16 | freq="D", 17 | ) 18 | 19 | result = arr.min() 20 | expected = pd.Period("2000-01-02", freq="D") 21 | assert result == expected 22 | 23 | result = arr.max() 24 | expected = pd.Period("2000-01-05", freq="D") 25 | assert result == expected 26 | 27 | result = arr.min(skipna=False) 28 | assert result is pd.NaT 29 | 30 | result = arr.max(skipna=False) 31 | assert result is pd.NaT 32 | 33 | def test_min_max_empty(self, skipna): 34 | arr = period_array([], freq="D") 35 | result = arr.min(skipna=skipna) 36 | assert result is pd.NaT 37 | 38 | result = arr.max(skipna=skipna) 39 | assert result is pd.NaT 40 | -------------------------------------------------------------------------------- /pandas/tests/arrays/sparse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/sparse/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/string_/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/string_/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/timedeltas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/arrays/timedeltas/__init__.py -------------------------------------------------------------------------------- /pandas/tests/arrays/timedeltas/test_cumulative.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas._testing as tm 4 | from pandas.core.arrays import TimedeltaArray 5 | 6 | 7 | class TestAccumulator: 8 | def test_accumulators_disallowed(self): 9 | # GH#50297 10 | arr = TimedeltaArray._from_sequence(["1D", "2D"], dtype="m8[ns]") 11 | with pytest.raises(TypeError, match="cumprod not supported"): 12 | arr._accumulate("cumprod") 13 | 14 | def test_cumsum(self, unit): 15 | # GH#50297 16 | dtype = f"m8[{unit}]" 17 | arr = TimedeltaArray._from_sequence(["1D", "2D"], dtype=dtype) 18 | result = arr._accumulate("cumsum") 19 | expected = TimedeltaArray._from_sequence(["1D", "3D"], dtype=dtype) 20 | tm.assert_timedelta_array_equal(result, expected) 21 | -------------------------------------------------------------------------------- /pandas/tests/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/base/__init__.py -------------------------------------------------------------------------------- /pandas/tests/base/common.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from pandas import Index 4 | 5 | 6 | def allow_na_ops(obj: Any) -> bool: 7 | """Whether to skip test cases including NaN""" 8 | is_bool_index = isinstance(obj, Index) and obj.inferred_type == "boolean" 9 | return not is_bool_index and obj._can_hold_na 10 | -------------------------------------------------------------------------------- /pandas/tests/computation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/computation/__init__.py -------------------------------------------------------------------------------- /pandas/tests/computation/test_compat.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas.compat._optional import VERSIONS 4 | 5 | import pandas as pd 6 | from pandas.core.computation import expr 7 | from pandas.core.computation.engines import ENGINES 8 | from pandas.util.version import Version 9 | 10 | 11 | def test_compat(): 12 | # test we have compat with our version of numexpr 13 | 14 | from pandas.core.computation.check import NUMEXPR_INSTALLED 15 | 16 | ne = pytest.importorskip("numexpr") 17 | 18 | ver = ne.__version__ 19 | if Version(ver) < Version(VERSIONS["numexpr"]): 20 | assert not NUMEXPR_INSTALLED 21 | else: 22 | assert NUMEXPR_INSTALLED 23 | 24 | 25 | @pytest.mark.parametrize("engine", ENGINES) 26 | @pytest.mark.parametrize("parser", expr.PARSERS) 27 | def test_invalid_numexpr_version(engine, parser): 28 | if engine == "numexpr": 29 | pytest.importorskip("numexpr") 30 | a, b = 1, 2 # noqa: F841 31 | res = pd.eval("a + b", engine=engine, parser=parser) 32 | assert res == 3 33 | -------------------------------------------------------------------------------- /pandas/tests/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/config/__init__.py -------------------------------------------------------------------------------- /pandas/tests/construction/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/construction/__init__.py -------------------------------------------------------------------------------- /pandas/tests/construction/test_extract_array.py: -------------------------------------------------------------------------------- 1 | from pandas import Index 2 | import pandas._testing as tm 3 | from pandas.core.construction import extract_array 4 | 5 | 6 | def test_extract_array_rangeindex(): 7 | ri = Index(range(5)) 8 | 9 | expected = ri._values 10 | res = extract_array(ri, extract_numpy=True, extract_range=True) 11 | tm.assert_numpy_array_equal(res, expected) 12 | res = extract_array(ri, extract_numpy=False, extract_range=True) 13 | tm.assert_numpy_array_equal(res, expected) 14 | 15 | res = extract_array(ri, extract_numpy=True, extract_range=False) 16 | tm.assert_index_equal(res, ri) 17 | res = extract_array(ri, extract_numpy=False, extract_range=False) 18 | tm.assert_index_equal(res, ri) 19 | -------------------------------------------------------------------------------- /pandas/tests/copy_view/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/copy_view/__init__.py -------------------------------------------------------------------------------- /pandas/tests/copy_view/index/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/copy_view/index/__init__.py -------------------------------------------------------------------------------- /pandas/tests/copy_view/index/test_periodindex.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | Period, 5 | PeriodIndex, 6 | Series, 7 | period_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | pytestmark = pytest.mark.filterwarnings( 12 | "ignore:Setting a value on a view:FutureWarning" 13 | ) 14 | 15 | 16 | @pytest.mark.parametrize("box", [lambda x: x, PeriodIndex]) 17 | def test_periodindex(box): 18 | dt = period_range("2019-12-31", periods=3, freq="D") 19 | ser = Series(dt) 20 | idx = box(PeriodIndex(ser)) 21 | expected = idx.copy(deep=True) 22 | ser.iloc[0] = Period("2020-12-31") 23 | tm.assert_index_equal(idx, expected) 24 | -------------------------------------------------------------------------------- /pandas/tests/copy_view/index/test_timedeltaindex.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | Series, 5 | Timedelta, 6 | TimedeltaIndex, 7 | timedelta_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | pytestmark = pytest.mark.filterwarnings( 12 | "ignore:Setting a value on a view:FutureWarning" 13 | ) 14 | 15 | 16 | @pytest.mark.parametrize( 17 | "cons", 18 | [ 19 | lambda x: TimedeltaIndex(x), 20 | lambda x: TimedeltaIndex(TimedeltaIndex(x)), 21 | ], 22 | ) 23 | def test_timedeltaindex(cons): 24 | dt = timedelta_range("1 day", periods=3) 25 | ser = Series(dt) 26 | idx = cons(ser) 27 | expected = idx.copy(deep=True) 28 | ser.iloc[0] = Timedelta("5 days") 29 | tm.assert_index_equal(idx, expected) 30 | -------------------------------------------------------------------------------- /pandas/tests/copy_view/test_chained_assignment_deprecation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas.errors import ChainedAssignmentError 5 | 6 | from pandas import DataFrame 7 | import pandas._testing as tm 8 | 9 | 10 | @pytest.mark.parametrize( 11 | "indexer", [0, [0, 1], slice(0, 2), np.array([True, False, True])] 12 | ) 13 | def test_series_setitem(indexer): 14 | # ensure we only get a single warning for those typical cases of chained 15 | # assignment 16 | df = DataFrame({"a": [1, 2, 3], "b": 1}) 17 | 18 | # using custom check instead of tm.assert_produces_warning because that doesn't 19 | # fail if multiple warnings are raised 20 | with pytest.warns() as record: # noqa: TID251 21 | df["a"][indexer] = 0 22 | assert len(record) == 1 23 | assert record[0].category == ChainedAssignmentError 24 | 25 | 26 | @pytest.mark.parametrize( 27 | "indexer", ["a", ["a", "b"], slice(0, 2), np.array([True, False, True])] 28 | ) 29 | def test_frame_setitem(indexer): 30 | df = DataFrame({"a": [1, 2, 3, 4, 5], "b": 1}) 31 | 32 | with tm.raises_chained_assignment_error(): 33 | df[0:3][indexer] = 10 34 | -------------------------------------------------------------------------------- /pandas/tests/copy_view/test_util.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import DataFrame 4 | from pandas.tests.copy_view.util import get_array 5 | 6 | 7 | def test_get_array_numpy(): 8 | df = DataFrame({"a": [1, 2, 3]}) 9 | assert np.shares_memory(get_array(df, "a"), get_array(df, "a")) 10 | 11 | 12 | def test_get_array_masked(): 13 | df = DataFrame({"a": [1, 2, 3]}, dtype="Int64") 14 | assert np.shares_memory(get_array(df, "a"), get_array(df, "a")) 15 | -------------------------------------------------------------------------------- /pandas/tests/copy_view/util.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | Categorical, 3 | Index, 4 | Series, 5 | ) 6 | from pandas.core.arrays import BaseMaskedArray 7 | 8 | 9 | def get_array(obj, col=None): 10 | """ 11 | Helper method to get array for a DataFrame column or a Series. 12 | 13 | Equivalent of df[col].values, but without going through normal getitem, 14 | which triggers tracking references / CoW (and we might be testing that 15 | this is done by some other operation). 16 | """ 17 | if isinstance(obj, Index): 18 | arr = obj._values 19 | elif isinstance(obj, Series) and (col is None or obj.name == col): 20 | arr = obj._values 21 | else: 22 | assert col is not None 23 | icol = obj.columns.get_loc(col) 24 | assert isinstance(icol, int) 25 | arr = obj._get_column_array(icol) 26 | if isinstance(arr, BaseMaskedArray): 27 | return arr._data 28 | elif isinstance(arr, Categorical): 29 | return arr 30 | return getattr(arr, "_ndarray", arr) 31 | -------------------------------------------------------------------------------- /pandas/tests/dtypes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/dtypes/__init__.py -------------------------------------------------------------------------------- /pandas/tests/dtypes/cast/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/dtypes/cast/__init__.py -------------------------------------------------------------------------------- /pandas/tests/dtypes/cast/test_construct_object_arr.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike 4 | 5 | 6 | @pytest.mark.parametrize("datum1", [1, 2.0, "3", (4, 5), [6, 7], None]) 7 | @pytest.mark.parametrize("datum2", [8, 9.0, "10", (11, 12), [13, 14], None]) 8 | def test_cast_1d_array(datum1, datum2): 9 | data = [datum1, datum2] 10 | result = construct_1d_object_array_from_listlike(data) 11 | 12 | # Direct comparison fails: https://github.com/numpy/numpy/issues/10218 13 | assert result.dtype == "object" 14 | assert list(result) == data 15 | 16 | 17 | @pytest.mark.parametrize("val", [1, 2.0, None]) 18 | def test_cast_1d_array_invalid_scalar(val): 19 | with pytest.raises(TypeError, match="has no len()"): 20 | construct_1d_object_array_from_listlike(val) 21 | -------------------------------------------------------------------------------- /pandas/tests/dtypes/cast/test_dict_compat.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas.core.dtypes.cast import dict_compat 4 | 5 | from pandas import Timestamp 6 | 7 | 8 | def test_dict_compat(): 9 | data_datetime64 = {np.datetime64("1990-03-15"): 1, np.datetime64("2015-03-15"): 2} 10 | data_unchanged = {1: 2, 3: 4, 5: 6} 11 | expected = {Timestamp("1990-3-15"): 1, Timestamp("2015-03-15"): 2} 12 | assert dict_compat(data_datetime64) == expected 13 | assert dict_compat(expected) == expected 14 | assert dict_compat(data_unchanged) == data_unchanged 15 | -------------------------------------------------------------------------------- /pandas/tests/dtypes/cast/test_infer_datetimelike.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | DataFrame, 6 | NaT, 7 | Series, 8 | Timestamp, 9 | ) 10 | 11 | 12 | @pytest.mark.parametrize( 13 | "data,exp_size", 14 | [ 15 | # see gh-16362. 16 | ([[NaT, "a", "b", 0], [NaT, "b", "c", 1]], 8), 17 | ([[NaT, "a", 0], [NaT, "b", 1]], 6), 18 | ], 19 | ) 20 | def test_maybe_infer_to_datetimelike_df_construct(data, exp_size): 21 | result = DataFrame(np.array(data)) 22 | assert result.size == exp_size 23 | 24 | 25 | def test_maybe_infer_to_datetimelike_ser_construct(): 26 | # see gh-19671. 27 | result = Series(["M1701", Timestamp("20130101")]) 28 | assert result.dtype.kind == "O" 29 | -------------------------------------------------------------------------------- /pandas/tests/dtypes/cast/test_maybe_box_native.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | from pandas.core.dtypes.cast import maybe_box_native 7 | 8 | from pandas import ( 9 | Interval, 10 | Period, 11 | Timedelta, 12 | Timestamp, 13 | ) 14 | 15 | 16 | @pytest.mark.parametrize( 17 | "obj,expected_dtype", 18 | [ 19 | (b"\x00\x10", bytes), 20 | ((4), int), 21 | (np.uint(4), int), 22 | (np.int32(-4), int), 23 | (np.uint8(4), int), 24 | (float(454.98), float), 25 | (np.float16(0.4), float), 26 | (np.float64(1.4), float), 27 | (np.bool_(False), bool), 28 | (datetime(2005, 2, 25), datetime), 29 | (np.datetime64("2005-02-25"), Timestamp), 30 | (Timestamp("2005-02-25"), Timestamp), 31 | (np.timedelta64(1, "D"), Timedelta), 32 | (Timedelta(1, "D"), Timedelta), 33 | (Interval(0, 1), Interval), 34 | (Period("4Q2005"), Period), 35 | ], 36 | ) 37 | def test_maybe_box_native(obj, expected_dtype): 38 | boxed_obj = maybe_box_native(obj) 39 | result_dtype = type(boxed_obj) 40 | assert result_dtype is expected_dtype 41 | -------------------------------------------------------------------------------- /pandas/tests/extension/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/extension/__init__.py -------------------------------------------------------------------------------- /pandas/tests/extension/array_with_attr/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.tests.extension.array_with_attr.array import ( 2 | FloatAttrArray, 3 | FloatAttrDtype, 4 | ) 5 | 6 | __all__ = ["FloatAttrArray", "FloatAttrDtype"] 7 | -------------------------------------------------------------------------------- /pandas/tests/extension/base/base.py: -------------------------------------------------------------------------------- 1 | class BaseExtensionTests: 2 | pass 3 | -------------------------------------------------------------------------------- /pandas/tests/extension/base/index.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for Indexes backed by arbitrary ExtensionArrays. 3 | """ 4 | 5 | import pandas as pd 6 | 7 | 8 | class BaseIndexTests: 9 | """Tests for Index object backed by an ExtensionArray""" 10 | 11 | def test_index_from_array(self, data): 12 | idx = pd.Index(data) 13 | assert data.dtype == idx.dtype 14 | 15 | def test_index_from_listlike_with_dtype(self, data): 16 | idx = pd.Index(data, dtype=data.dtype) 17 | assert idx.dtype == data.dtype 18 | 19 | idx = pd.Index(list(data), dtype=data.dtype) 20 | assert idx.dtype == data.dtype 21 | -------------------------------------------------------------------------------- /pandas/tests/extension/base/printing.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | import pytest 4 | 5 | import pandas as pd 6 | 7 | 8 | class BasePrintingTests: 9 | """Tests checking the formatting of your EA when printed.""" 10 | 11 | @pytest.mark.parametrize("size", ["big", "small"]) 12 | def test_array_repr(self, data, size): 13 | if size == "small": 14 | data = data[:5] 15 | else: 16 | data = type(data)._concat_same_type([data] * 5) 17 | 18 | result = repr(data) 19 | assert type(data).__name__ in result 20 | assert f"Length: {len(data)}" in result 21 | assert str(data.dtype) in result 22 | if size == "big": 23 | assert "..." in result 24 | 25 | def test_array_repr_unicode(self, data): 26 | result = str(data) 27 | assert isinstance(result, str) 28 | 29 | def test_series_repr(self, data): 30 | ser = pd.Series(data) 31 | assert data.dtype.name in repr(ser) 32 | 33 | def test_dataframe_repr(self, data): 34 | df = pd.DataFrame({"A": data}) 35 | repr(df) 36 | 37 | def test_dtype_name_in_info(self, data): 38 | buf = io.StringIO() 39 | pd.DataFrame({"A": data}).info(buf=buf) 40 | result = buf.getvalue() 41 | assert data.dtype.name in result 42 | -------------------------------------------------------------------------------- /pandas/tests/extension/date/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.tests.extension.date.array import ( 2 | DateArray, 3 | DateDtype, 4 | ) 5 | 6 | __all__ = ["DateArray", "DateDtype"] 7 | -------------------------------------------------------------------------------- /pandas/tests/extension/decimal/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.tests.extension.decimal.array import ( 2 | DecimalArray, 3 | DecimalDtype, 4 | make_data, 5 | to_decimal, 6 | ) 7 | 8 | __all__ = ["DecimalArray", "DecimalDtype", "make_data", "to_decimal"] 9 | -------------------------------------------------------------------------------- /pandas/tests/extension/json/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.tests.extension.json.array import ( 2 | JSONArray, 3 | JSONDtype, 4 | make_data, 5 | ) 6 | 7 | __all__ = ["JSONArray", "JSONDtype", "make_data"] 8 | -------------------------------------------------------------------------------- /pandas/tests/extension/list/__init__.py: -------------------------------------------------------------------------------- 1 | from pandas.tests.extension.list.array import ( 2 | ListArray, 3 | ListDtype, 4 | make_data, 5 | ) 6 | 7 | __all__ = ["ListArray", "ListDtype", "make_data"] 8 | -------------------------------------------------------------------------------- /pandas/tests/extension/list/test_list.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas as pd 4 | from pandas.tests.extension.list.array import ( 5 | ListArray, 6 | ListDtype, 7 | make_data, 8 | ) 9 | 10 | 11 | @pytest.fixture 12 | def dtype(): 13 | return ListDtype() 14 | 15 | 16 | @pytest.fixture 17 | def data(): 18 | """Length-100 ListArray for semantics test.""" 19 | data = make_data() 20 | 21 | while len(data[0]) == len(data[1]): 22 | data = make_data() 23 | 24 | return ListArray(data) 25 | 26 | 27 | def test_to_csv(data): 28 | # https://github.com/pandas-dev/pandas/issues/28840 29 | # array with list-likes fail when doing astype(str) on the numpy array 30 | # which was done in get_values_for_csv 31 | df = pd.DataFrame({"a": data}) 32 | res = df.to_csv() 33 | assert str(data[0]) in res 34 | -------------------------------------------------------------------------------- /pandas/tests/extension/test_extension.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for behavior if an author does *not* implement EA methods. 3 | """ 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | from pandas.core.arrays import ExtensionArray 9 | 10 | 11 | class MyEA(ExtensionArray): 12 | def __init__(self, values) -> None: 13 | self._values = values 14 | 15 | 16 | @pytest.fixture 17 | def data(): 18 | arr = np.arange(10) 19 | return MyEA(arr) 20 | 21 | 22 | class TestExtensionArray: 23 | def test_errors(self, data, all_arithmetic_operators): 24 | # invalid ops 25 | op_name = all_arithmetic_operators 26 | with pytest.raises(AttributeError): 27 | getattr(data, op_name) 28 | -------------------------------------------------------------------------------- /pandas/tests/frame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/frame/__init__.py -------------------------------------------------------------------------------- /pandas/tests/frame/constructors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/frame/constructors/__init__.py -------------------------------------------------------------------------------- /pandas/tests/frame/indexing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/frame/indexing/__init__.py -------------------------------------------------------------------------------- /pandas/tests/frame/indexing/test_get.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import DataFrame 4 | import pandas._testing as tm 5 | 6 | 7 | class TestGet: 8 | def test_get(self, float_frame): 9 | b = float_frame.get("B") 10 | tm.assert_series_equal(b, float_frame["B"]) 11 | 12 | assert float_frame.get("foo") is None 13 | tm.assert_series_equal( 14 | float_frame.get("foo", float_frame["B"]), float_frame["B"] 15 | ) 16 | 17 | @pytest.mark.parametrize( 18 | "columns, index", 19 | [ 20 | [None, None], 21 | [list("AB"), None], 22 | [list("AB"), range(3)], 23 | ], 24 | ) 25 | def test_get_none(self, columns, index): 26 | # see gh-5652 27 | assert DataFrame(columns=columns, index=index).get(None) is None 28 | -------------------------------------------------------------------------------- /pandas/tests/frame/indexing/test_get_value.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | DataFrame, 5 | MultiIndex, 6 | ) 7 | 8 | 9 | class TestGetValue: 10 | def test_get_set_value_no_partial_indexing(self): 11 | # partial w/ MultiIndex raise exception 12 | index = MultiIndex.from_tuples([(0, 1), (0, 2), (1, 1), (1, 2)]) 13 | df = DataFrame(index=index, columns=range(4)) 14 | with pytest.raises(KeyError, match=r"^0$"): 15 | df._get_value(0, 1) 16 | 17 | def test_get_value(self, float_frame): 18 | for idx in float_frame.index: 19 | for col in float_frame.columns: 20 | result = float_frame._get_value(idx, col) 21 | expected = float_frame[col][idx] 22 | assert result == expected 23 | -------------------------------------------------------------------------------- /pandas/tests/frame/methods/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Test files dedicated to individual (stand-alone) DataFrame methods 3 | 4 | Ideally these files/tests should correspond 1-to-1 with tests.series.methods 5 | 6 | These may also present opportunities for sharing/de-duplicating test code. 7 | """ 8 | -------------------------------------------------------------------------------- /pandas/tests/frame/methods/test_count.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | DataFrame, 3 | Series, 4 | ) 5 | import pandas._testing as tm 6 | 7 | 8 | class TestDataFrameCount: 9 | def test_count(self): 10 | # corner case 11 | frame = DataFrame() 12 | ct1 = frame.count(1) 13 | assert isinstance(ct1, Series) 14 | 15 | ct2 = frame.count(0) 16 | assert isinstance(ct2, Series) 17 | 18 | # GH#423 19 | df = DataFrame(index=range(10)) 20 | result = df.count(1) 21 | expected = Series(0, index=df.index) 22 | tm.assert_series_equal(result, expected) 23 | 24 | df = DataFrame(columns=range(10)) 25 | result = df.count(0) 26 | expected = Series(0, index=df.columns) 27 | tm.assert_series_equal(result, expected) 28 | 29 | df = DataFrame() 30 | result = df.count() 31 | expected = Series(dtype="int64") 32 | tm.assert_series_equal(result, expected) 33 | 34 | def test_count_objects(self, float_string_frame): 35 | dm = DataFrame(float_string_frame._series) 36 | df = DataFrame(float_string_frame._series) 37 | 38 | tm.assert_series_equal(dm.count(), df.count()) 39 | tm.assert_series_equal(dm.count(1), df.count(1)) 40 | -------------------------------------------------------------------------------- /pandas/tests/frame/methods/test_iterrows.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | DataFrame, 3 | Timedelta, 4 | ) 5 | 6 | 7 | def test_no_overflow_of_freq_and_time_in_dataframe(): 8 | # GH 35665 9 | df = DataFrame( 10 | { 11 | "some_string": ["2222Y3"], 12 | "time": [Timedelta("0 days 00:00:00.990000")], 13 | } 14 | ) 15 | for _, row in df.iterrows(): 16 | assert row.dtype == "object" 17 | -------------------------------------------------------------------------------- /pandas/tests/frame/methods/test_pipe.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | DataFrame, 5 | Series, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestPipe: 11 | def test_pipe(self, frame_or_series): 12 | obj = DataFrame({"A": [1, 2, 3]}) 13 | expected = DataFrame({"A": [1, 4, 9]}) 14 | if frame_or_series is Series: 15 | obj = obj["A"] 16 | expected = expected["A"] 17 | 18 | f = lambda x, y: x**y 19 | result = obj.pipe(f, 2) 20 | tm.assert_equal(result, expected) 21 | 22 | def test_pipe_tuple(self, frame_or_series): 23 | obj = DataFrame({"A": [1, 2, 3]}) 24 | obj = tm.get_obj(obj, frame_or_series) 25 | 26 | f = lambda x, y: y 27 | result = obj.pipe((f, "y"), 0) 28 | tm.assert_equal(result, obj) 29 | 30 | def test_pipe_tuple_error(self, frame_or_series): 31 | obj = DataFrame({"A": [1, 2, 3]}) 32 | obj = tm.get_obj(obj, frame_or_series) 33 | 34 | f = lambda x, y: y 35 | 36 | msg = "y is both the pipe target and a keyword argument" 37 | 38 | with pytest.raises(ValueError, match=msg): 39 | obj.pipe((f, "y"), x=1, y=0) 40 | -------------------------------------------------------------------------------- /pandas/tests/frame/methods/test_size.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import DataFrame 5 | 6 | 7 | @pytest.mark.parametrize( 8 | "data, index, expected", 9 | [ 10 | ({"col1": [1], "col2": [3]}, None, 2), 11 | ({}, None, 0), 12 | ({"col1": [1, np.nan], "col2": [3, 4]}, None, 4), 13 | ({"col1": [1, 2], "col2": [3, 4]}, [["a", "b"], [1, 2]], 4), 14 | ({"col1": [1, 2, 3, 4], "col2": [3, 4, 5, 6]}, ["x", "y", "a", "b"], 8), 15 | ], 16 | ) 17 | def test_size(data, index, expected): 18 | # GH#52897 19 | df = DataFrame(data, index=index) 20 | assert df.size == expected 21 | assert isinstance(df.size, int) 22 | -------------------------------------------------------------------------------- /pandas/tests/frame/test_alter_axes.py: -------------------------------------------------------------------------------- 1 | from datetime import ( 2 | datetime, 3 | timezone, 4 | ) 5 | 6 | from pandas import DataFrame 7 | import pandas._testing as tm 8 | 9 | 10 | class TestDataFrameAlterAxes: 11 | # Tests for setting index/columns attributes directly (i.e. __setattr__) 12 | 13 | def test_set_axis_setattr_index(self): 14 | # GH 6785 15 | # set the index manually 16 | 17 | df = DataFrame([{"ts": datetime(2014, 4, 1, tzinfo=timezone.utc), "foo": 1}]) 18 | expected = df.set_index("ts") 19 | df.index = df["ts"] 20 | df.pop("ts") 21 | tm.assert_frame_equal(df, expected) 22 | 23 | # Renaming 24 | 25 | def test_assign_columns(self, float_frame): 26 | float_frame["hi"] = "there" 27 | 28 | df = float_frame.copy() 29 | df.columns = ["foo", "bar", "baz", "quux", "foo2"] 30 | tm.assert_series_equal(float_frame["C"], df["baz"], check_names=False) 31 | tm.assert_series_equal(float_frame["hi"], df["foo2"], check_names=False) 32 | -------------------------------------------------------------------------------- /pandas/tests/frame/test_validate.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas.core.frame import DataFrame 4 | 5 | 6 | class TestDataFrameValidate: 7 | """Tests for error handling related to data types of method arguments.""" 8 | 9 | @pytest.mark.parametrize( 10 | "func", 11 | [ 12 | "query", 13 | "eval", 14 | "set_index", 15 | "reset_index", 16 | "dropna", 17 | "drop_duplicates", 18 | "sort_values", 19 | ], 20 | ) 21 | @pytest.mark.parametrize("inplace", [1, "True", [1, 2, 3], 5.0]) 22 | def test_validate_bool_args(self, func, inplace): 23 | dataframe = DataFrame({"a": [1, 2], "b": [3, 4]}) 24 | msg = 'For argument "inplace" expected type bool' 25 | kwargs = {"inplace": inplace} 26 | 27 | if func == "query": 28 | kwargs["expr"] = "a > b" 29 | elif func == "eval": 30 | kwargs["expr"] = "a + b" 31 | elif func == "set_index": 32 | kwargs["keys"] = ["a"] 33 | elif func == "sort_values": 34 | kwargs["by"] = ["a"] 35 | 36 | with pytest.raises(ValueError, match=msg): 37 | getattr(dataframe, func)(**kwargs) 38 | -------------------------------------------------------------------------------- /pandas/tests/generic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/generic/__init__.py -------------------------------------------------------------------------------- /pandas/tests/groupby/__init__.py: -------------------------------------------------------------------------------- 1 | def get_groupby_method_args(name, obj): 2 | """ 3 | Get required arguments for a groupby method. 4 | 5 | When parametrizing a test over groupby methods (e.g. "sum", "mean"), 6 | it is often the case that arguments are required for certain methods. 7 | 8 | Parameters 9 | ---------- 10 | name: str 11 | Name of the method. 12 | obj: Series or DataFrame 13 | pandas object that is being grouped. 14 | 15 | Returns 16 | ------- 17 | A tuple of required arguments for the method. 18 | """ 19 | if name in ("nth", "take"): 20 | return (0,) 21 | if name == "quantile": 22 | return (0.5,) 23 | if name == "corrwith": 24 | return (obj,) 25 | return () 26 | -------------------------------------------------------------------------------- /pandas/tests/groupby/aggregate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/groupby/aggregate/__init__.py -------------------------------------------------------------------------------- /pandas/tests/groupby/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/groupby/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/groupby/methods/test_skew.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import pandas as pd 4 | import pandas._testing as tm 5 | 6 | 7 | def test_groupby_skew_equivalence(): 8 | # Test that that groupby skew method (which uses libgroupby.group_skew) 9 | # matches the results of operating group-by-group (which uses nanops.nanskew) 10 | nrows = 1000 11 | ngroups = 3 12 | ncols = 2 13 | nan_frac = 0.05 14 | 15 | arr = np.random.default_rng(2).standard_normal((nrows, ncols)) 16 | arr[np.random.default_rng(2).random(nrows) < nan_frac] = np.nan 17 | 18 | df = pd.DataFrame(arr) 19 | grps = np.random.default_rng(2).integers(0, ngroups, size=nrows) 20 | gb = df.groupby(grps) 21 | 22 | result = gb.skew() 23 | 24 | grpwise = [grp.skew().to_frame(i).T for i, grp in gb] 25 | expected = pd.concat(grpwise, axis=0) 26 | expected.index = expected.index.astype(result.index.dtype) # 32bit builds 27 | tm.assert_frame_equal(result, expected) 28 | -------------------------------------------------------------------------------- /pandas/tests/groupby/transform/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/groupby/transform/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/base_class/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/base_class/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/base_class/test_pickle.py: -------------------------------------------------------------------------------- 1 | from pandas import Index 2 | import pandas._testing as tm 3 | 4 | 5 | def test_pickle_preserves_object_dtype(): 6 | # GH#43188, GH#43155 don't infer numeric dtype 7 | index = Index([1, 2, 3], dtype=object) 8 | 9 | result = tm.round_trip_pickle(index) 10 | assert result.dtype == object 11 | tm.assert_index_equal(index, result) 12 | -------------------------------------------------------------------------------- /pandas/tests/indexes/base_class/test_where.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import Index 4 | import pandas._testing as tm 5 | 6 | 7 | class TestWhere: 8 | def test_where_intlike_str_doesnt_cast_ints(self): 9 | idx = Index(range(3)) 10 | mask = np.array([True, False, True]) 11 | res = idx.where(mask, "2") 12 | expected = Index([0, "2", 2]) 13 | tm.assert_index_equal(res, expected) 14 | -------------------------------------------------------------------------------- /pandas/tests/indexes/categorical/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/categorical/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/categorical/test_setops.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | CategoricalIndex, 6 | Index, 7 | ) 8 | import pandas._testing as tm 9 | 10 | 11 | @pytest.mark.parametrize("na_value", [None, np.nan]) 12 | def test_difference_with_na(na_value): 13 | # GH 57318 14 | ci = CategoricalIndex(["a", "b", "c", None]) 15 | other = Index(["c", na_value]) 16 | result = ci.difference(other) 17 | expected = CategoricalIndex(["a", "b"], categories=["a", "b", "c"]) 18 | tm.assert_index_equal(result, expected) 19 | -------------------------------------------------------------------------------- /pandas/tests/indexes/conftest.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | Series, 6 | array, 7 | ) 8 | 9 | 10 | @pytest.fixture(params=[None, False]) 11 | def sort(request): 12 | """ 13 | Valid values for the 'sort' parameter used in the Index 14 | setops methods (intersection, union, etc.) 15 | 16 | Caution: 17 | Don't confuse this one with the "sort" fixture used 18 | for concat. That one has parameters [True, False]. 19 | 20 | We can't combine them as sort=True is not permitted 21 | in the Index setops methods. 22 | """ 23 | return request.param 24 | 25 | 26 | @pytest.fixture(params=["D", "3D", "-3D", "h", "2h", "-2h", "min", "2min", "s", "-3s"]) 27 | def freq_sample(request): 28 | """ 29 | Valid values for 'freq' parameter used to create date_range and 30 | timedelta_range.. 31 | """ 32 | return request.param 33 | 34 | 35 | @pytest.fixture(params=[list, tuple, np.array, array, Series]) 36 | def listlike_box(request): 37 | """ 38 | Types that may be passed as the indexer to searchsorted. 39 | """ 40 | return request.param 41 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimelike_/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/datetimelike_/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimelike_/test_nat.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | DatetimeIndex, 6 | NaT, 7 | PeriodIndex, 8 | TimedeltaIndex, 9 | ) 10 | import pandas._testing as tm 11 | 12 | 13 | @pytest.mark.parametrize( 14 | "index_without_na", 15 | [ 16 | TimedeltaIndex(["1 days", "2 days"]), 17 | PeriodIndex(["2011-01-01", "2011-01-02"], freq="D"), 18 | DatetimeIndex(["2011-01-01", "2011-01-02"]), 19 | DatetimeIndex(["2011-01-01", "2011-01-02"], tz="UTC"), 20 | ], 21 | ) 22 | def test_nat(index_without_na): 23 | empty_index = index_without_na[:0] 24 | 25 | index_with_na = index_without_na.copy(deep=True) 26 | index_with_na._data[1] = NaT 27 | 28 | assert empty_index._na_value is NaT 29 | assert index_with_na._na_value is NaT 30 | assert index_without_na._na_value is NaT 31 | 32 | idx = index_without_na 33 | assert idx._can_hold_na 34 | 35 | tm.assert_numpy_array_equal(idx._isnan, np.array([False, False])) 36 | assert idx.hasnans is False 37 | 38 | idx = index_with_na 39 | assert idx._can_hold_na 40 | 41 | tm.assert_numpy_array_equal(idx._isnan, np.array([False, True])) 42 | assert idx.hasnans is True 43 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/datetimes/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/datetimes/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/test_asof.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta 2 | 3 | from pandas import ( 4 | Index, 5 | Timestamp, 6 | date_range, 7 | isna, 8 | ) 9 | 10 | 11 | class TestAsOf: 12 | def test_asof_partial(self): 13 | index = date_range("2010-01-01", periods=2, freq="ME") 14 | expected = Timestamp("2010-02-28") 15 | result = index.asof("2010-02") 16 | assert result == expected 17 | assert not isinstance(result, Index) 18 | 19 | def test_asof(self): 20 | index = date_range("2020-01-01", periods=10) 21 | 22 | dt = index[0] 23 | assert index.asof(dt) == dt 24 | assert isna(index.asof(dt - timedelta(1))) 25 | 26 | dt = index[-1] 27 | assert index.asof(dt + timedelta(1)) == dt 28 | 29 | dt = index[0].to_pydatetime() 30 | assert isinstance(index.asof(dt), Timestamp) 31 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/test_isocalendar.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | DataFrame, 3 | DatetimeIndex, 4 | date_range, 5 | ) 6 | import pandas._testing as tm 7 | 8 | 9 | def test_isocalendar_returns_correct_values_close_to_new_year_with_tz(): 10 | # GH#6538: Check that DatetimeIndex and its TimeStamp elements 11 | # return the same weekofyear accessor close to new year w/ tz 12 | dates = ["2013/12/29", "2013/12/30", "2013/12/31"] 13 | dates = DatetimeIndex(dates, tz="Europe/Brussels") 14 | result = dates.isocalendar() 15 | expected_data_frame = DataFrame( 16 | [[2013, 52, 7], [2014, 1, 1], [2014, 1, 2]], 17 | columns=["year", "week", "day"], 18 | index=dates, 19 | dtype="UInt32", 20 | ) 21 | tm.assert_frame_equal(result, expected_data_frame) 22 | 23 | 24 | def test_dti_timestamp_isocalendar_fields(): 25 | idx = date_range("2020-01-01", periods=10) 26 | expected = tuple(idx.isocalendar().iloc[-1].to_list()) 27 | result = idx[-1].isocalendar() 28 | assert result == expected 29 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/test_resolution.py: -------------------------------------------------------------------------------- 1 | from dateutil.tz import tzlocal 2 | import pytest 3 | 4 | from pandas.compat import ( 5 | IS64, 6 | WASM, 7 | ) 8 | 9 | from pandas import date_range 10 | 11 | 12 | @pytest.mark.parametrize( 13 | "freq,expected", 14 | [ 15 | ("YE", "day"), 16 | ("QE", "day"), 17 | ("ME", "day"), 18 | ("D", "day"), 19 | ("h", "hour"), 20 | ("min", "minute"), 21 | ("s", "second"), 22 | ("ms", "millisecond"), 23 | ("us", "microsecond"), 24 | ], 25 | ) 26 | @pytest.mark.skipif(WASM, reason="OverflowError received on WASM") 27 | def test_dti_resolution(request, tz_naive_fixture, freq, expected): 28 | tz = tz_naive_fixture 29 | if freq == "YE" and ((not IS64) or WASM) and isinstance(tz, tzlocal): 30 | request.applymarker( 31 | pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038") 32 | ) 33 | 34 | idx = date_range(start="2013-04-01", periods=30, freq=freq, tz=tz) 35 | assert idx.resolution == expected 36 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/test_to_frame.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | DataFrame, 3 | Index, 4 | date_range, 5 | ) 6 | import pandas._testing as tm 7 | 8 | 9 | class TestToFrame: 10 | def test_to_frame_datetime_tz(self): 11 | # GH#25809 12 | idx = date_range(start="2019-01-01", end="2019-01-30", freq="D", tz="UTC") 13 | result = idx.to_frame() 14 | expected = DataFrame(idx, index=idx) 15 | tm.assert_frame_equal(result, expected) 16 | 17 | def test_to_frame_respects_none_name(self): 18 | # GH#44212 if we explicitly pass name=None, then that should be respected, 19 | # not changed to 0 20 | # GH-45448 this is first deprecated to only change in the future 21 | idx = date_range(start="2019-01-01", end="2019-01-30", freq="D", tz="UTC") 22 | result = idx.to_frame(name=None) 23 | exp_idx = Index([None], dtype=object) 24 | tm.assert_index_equal(exp_idx, result.columns) 25 | 26 | result = idx.rename("foo").to_frame(name=None) 27 | exp_idx = Index([None], dtype=object) 28 | tm.assert_index_equal(exp_idx, result.columns) 29 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/methods/test_to_series.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | DatetimeIndex, 5 | Series, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestToSeries: 11 | def test_to_series(self): 12 | naive = DatetimeIndex(["2013-1-1 13:00", "2013-1-2 14:00"], name="B") 13 | idx = naive.tz_localize("US/Pacific") 14 | 15 | expected = Series(np.array(idx.tolist(), dtype="object"), name="B") 16 | result = idx.to_series(index=range(2)) 17 | assert expected.dtype == idx.dtype 18 | tm.assert_series_equal(result, expected) 19 | -------------------------------------------------------------------------------- /pandas/tests/indexes/datetimes/test_npfuncs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import date_range 4 | import pandas._testing as tm 5 | 6 | 7 | class TestSplit: 8 | def test_split_non_utc(self): 9 | # GH#14042 10 | indices = date_range("2016-01-01 00:00:00+0200", freq="s", periods=10) 11 | result = np.split(indices, indices_or_sections=[])[0] 12 | expected = indices._with_freq(None) 13 | tm.assert_index_equal(result, expected) 14 | -------------------------------------------------------------------------------- /pandas/tests/indexes/interval/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/interval/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/interval/test_join.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | IntervalIndex, 5 | MultiIndex, 6 | RangeIndex, 7 | ) 8 | import pandas._testing as tm 9 | 10 | 11 | @pytest.fixture 12 | def range_index(): 13 | return RangeIndex(3, name="range_index") 14 | 15 | 16 | @pytest.fixture 17 | def interval_index(): 18 | return IntervalIndex.from_tuples( 19 | [(0.0, 1.0), (1.0, 2.0), (1.5, 2.5)], name="interval_index" 20 | ) 21 | 22 | 23 | def test_join_overlapping_in_mi_to_same_intervalindex(range_index, interval_index): 24 | # GH-45661 25 | multi_index = MultiIndex.from_product([interval_index, range_index]) 26 | result = multi_index.join(interval_index) 27 | 28 | tm.assert_index_equal(result, multi_index) 29 | 30 | 31 | def test_join_overlapping_to_multiindex_with_same_interval(range_index, interval_index): 32 | # GH-45661 33 | multi_index = MultiIndex.from_product([interval_index, range_index]) 34 | result = interval_index.join(multi_index) 35 | 36 | tm.assert_index_equal(result, multi_index) 37 | 38 | 39 | def test_join_overlapping_interval_to_another_intervalindex(interval_index): 40 | # GH-45661 41 | flipped_interval_index = interval_index[::-1] 42 | result = interval_index.join(flipped_interval_index) 43 | 44 | tm.assert_index_equal(result, interval_index) 45 | -------------------------------------------------------------------------------- /pandas/tests/indexes/interval/test_pickle.py: -------------------------------------------------------------------------------- 1 | from pandas import IntervalIndex 2 | import pandas._testing as tm 3 | 4 | 5 | class TestPickle: 6 | def test_pickle_round_trip_closed(self, closed): 7 | # https://github.com/pandas-dev/pandas/issues/35658 8 | idx = IntervalIndex.from_tuples([(1, 2), (2, 3)], closed=closed) 9 | result = tm.round_trip_pickle(idx) 10 | tm.assert_index_equal(result, idx) 11 | -------------------------------------------------------------------------------- /pandas/tests/indexes/multi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/multi/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/multi/conftest.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | Index, 6 | MultiIndex, 7 | ) 8 | 9 | 10 | # Note: identical the "multi" entry in the top-level "index" fixture 11 | @pytest.fixture 12 | def idx(): 13 | # a MultiIndex used to test the general functionality of the 14 | # general functionality of this object 15 | major_axis = Index(["foo", "bar", "baz", "qux"]) 16 | minor_axis = Index(["one", "two"]) 17 | 18 | major_codes = np.array([0, 0, 1, 2, 3, 3]) 19 | minor_codes = np.array([0, 1, 0, 1, 0, 1]) 20 | index_names = ["first", "second"] 21 | mi = MultiIndex( 22 | levels=[major_axis, minor_axis], 23 | codes=[major_codes, minor_codes], 24 | names=index_names, 25 | verify_integrity=False, 26 | ) 27 | return mi 28 | -------------------------------------------------------------------------------- /pandas/tests/indexes/multi/test_astype.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas.core.dtypes.dtypes import CategoricalDtype 5 | 6 | import pandas._testing as tm 7 | 8 | 9 | def test_astype(idx): 10 | expected = idx.copy() 11 | actual = idx.astype("O") 12 | tm.assert_copy(actual.levels, expected.levels) 13 | tm.assert_copy(actual.codes, expected.codes) 14 | assert actual.names == list(expected.names) 15 | 16 | with pytest.raises(TypeError, match="^Setting.*dtype.*object"): 17 | idx.astype(np.dtype(int)) 18 | 19 | 20 | @pytest.mark.parametrize("ordered", [True, False]) 21 | def test_astype_category(idx, ordered): 22 | # GH 18630 23 | msg = "> 1 ndim Categorical are not supported at this time" 24 | with pytest.raises(NotImplementedError, match=msg): 25 | idx.astype(CategoricalDtype(ordered=ordered)) 26 | 27 | if ordered is False: 28 | # dtype='category' defaults to ordered=False, so only test once 29 | with pytest.raises(NotImplementedError, match=msg): 30 | idx.astype("category") 31 | -------------------------------------------------------------------------------- /pandas/tests/indexes/multi/test_pickle.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import MultiIndex 4 | 5 | 6 | def test_pickle_compat_construction(): 7 | # this is testing for pickle compat 8 | # need an object to create with 9 | with pytest.raises(TypeError, match="Must pass both levels and codes"): 10 | MultiIndex() 11 | -------------------------------------------------------------------------------- /pandas/tests/indexes/numeric/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/numeric/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/object/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/object/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/object/test_astype.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import ( 4 | Index, 5 | NaT, 6 | ) 7 | 8 | 9 | def test_astype_invalid_nas_to_tdt64_raises(): 10 | # GH#45722 don't cast np.datetime64 NaTs to timedelta64 NaT 11 | idx = Index([NaT.asm8] * 2, dtype=object) 12 | 13 | msg = r"Invalid type for timedelta scalar: " 14 | with pytest.raises(TypeError, match=msg): 15 | idx.astype("m8[ns]") 16 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/period/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/period/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/period/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/period/methods/test_fillna.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | Index, 3 | NaT, 4 | Period, 5 | PeriodIndex, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestFillNA: 11 | def test_fillna_period(self): 12 | # GH#11343 13 | idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="h") 14 | 15 | exp = PeriodIndex( 16 | ["2011-01-01 09:00", "2011-01-01 10:00", "2011-01-01 11:00"], freq="h" 17 | ) 18 | result = idx.fillna(Period("2011-01-01 10:00", freq="h")) 19 | tm.assert_index_equal(result, exp) 20 | 21 | exp = Index( 22 | [ 23 | Period("2011-01-01 09:00", freq="h"), 24 | "x", 25 | Period("2011-01-01 11:00", freq="h"), 26 | ], 27 | dtype=object, 28 | ) 29 | result = idx.fillna("x") 30 | tm.assert_index_equal(result, exp) 31 | 32 | exp = Index( 33 | [ 34 | Period("2011-01-01 09:00", freq="h"), 35 | Period("2011-01-01", freq="D"), 36 | Period("2011-01-01 11:00", freq="h"), 37 | ], 38 | dtype=object, 39 | ) 40 | result = idx.fillna(Period("2011-01-01", freq="D")) 41 | tm.assert_index_equal(result, exp) 42 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/methods/test_insert.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | NaT, 6 | PeriodIndex, 7 | period_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | 12 | class TestInsert: 13 | @pytest.mark.parametrize("na", [np.nan, NaT, None]) 14 | def test_insert(self, na): 15 | # GH#18295 (test missing) 16 | expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q") 17 | result = period_range("2017Q1", periods=4, freq="Q").insert(1, na) 18 | tm.assert_index_equal(result, expected) 19 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/methods/test_is_full.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import PeriodIndex 4 | 5 | 6 | def test_is_full(): 7 | index = PeriodIndex([2005, 2007, 2009], freq="Y") 8 | assert not index.is_full 9 | 10 | index = PeriodIndex([2005, 2006, 2007], freq="Y") 11 | assert index.is_full 12 | 13 | index = PeriodIndex([2005, 2005, 2007], freq="Y") 14 | assert not index.is_full 15 | 16 | index = PeriodIndex([2005, 2005, 2006], freq="Y") 17 | assert index.is_full 18 | 19 | index = PeriodIndex([2006, 2005, 2005], freq="Y") 20 | with pytest.raises(ValueError, match="Index is not monotonic"): 21 | index.is_full 22 | 23 | assert index[:0].is_full 24 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/methods/test_repeat.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | PeriodIndex, 6 | period_range, 7 | ) 8 | import pandas._testing as tm 9 | 10 | 11 | class TestRepeat: 12 | @pytest.mark.parametrize("use_numpy", [True, False]) 13 | @pytest.mark.parametrize( 14 | "index", 15 | [ 16 | period_range("2000-01-01", periods=3, freq="D"), 17 | period_range("2001-01-01", periods=3, freq="2D"), 18 | PeriodIndex(["2001-01", "NaT", "2003-01"], freq="M"), 19 | ], 20 | ) 21 | def test_repeat_freqstr(self, index, use_numpy): 22 | # GH#10183 23 | expected = PeriodIndex([per for per in index for _ in range(3)]) 24 | result = np.repeat(index, 3) if use_numpy else index.repeat(3) 25 | tm.assert_index_equal(result, expected) 26 | assert result.freqstr == index.freqstr 27 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/test_freq_attr.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas.compat import PY311 4 | 5 | from pandas import ( 6 | offsets, 7 | period_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | 12 | class TestFreq: 13 | def test_freq_setter_deprecated(self): 14 | # GH#20678 15 | idx = period_range("2018Q1", periods=4, freq="Q") 16 | 17 | # no warning for getter 18 | with tm.assert_produces_warning(None): 19 | idx.freq 20 | 21 | # warning for setter 22 | msg = ( 23 | "property 'freq' of 'PeriodArray' object has no setter" 24 | if PY311 25 | else "can't set attribute" 26 | ) 27 | with pytest.raises(AttributeError, match=msg): 28 | idx.freq = offsets.Day() 29 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/test_pickle.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | NaT, 6 | PeriodIndex, 7 | period_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | from pandas.tseries import offsets 12 | 13 | 14 | class TestPickle: 15 | @pytest.mark.parametrize("freq", ["D", "M", "Y"]) 16 | def test_pickle_round_trip(self, freq): 17 | idx = PeriodIndex(["2016-05-16", "NaT", NaT, np.nan], freq=freq) 18 | result = tm.round_trip_pickle(idx) 19 | tm.assert_index_equal(result, idx) 20 | 21 | def test_pickle_freq(self): 22 | # GH#2891 23 | prng = period_range("1/1/2011", "1/1/2012", freq="M") 24 | new_prng = tm.round_trip_pickle(prng) 25 | assert new_prng.freq == offsets.MonthEnd() 26 | assert new_prng.freqstr == "M" 27 | -------------------------------------------------------------------------------- /pandas/tests/indexes/period/test_resolution.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas as pd 4 | 5 | 6 | class TestResolution: 7 | @pytest.mark.parametrize( 8 | "freq,expected", 9 | [ 10 | ("Y", "year"), 11 | ("Q", "quarter"), 12 | ("M", "month"), 13 | ("D", "day"), 14 | ("h", "hour"), 15 | ("min", "minute"), 16 | ("s", "second"), 17 | ("ms", "millisecond"), 18 | ("us", "microsecond"), 19 | ], 20 | ) 21 | def test_resolution(self, freq, expected): 22 | idx = pd.period_range(start="2013-04-01", periods=30, freq=freq) 23 | assert idx.resolution == expected 24 | -------------------------------------------------------------------------------- /pandas/tests/indexes/ranges/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/ranges/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/string/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/string/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/string/test_astype.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | Index, 3 | Series, 4 | ) 5 | import pandas._testing as tm 6 | 7 | 8 | def test_astype_str_from_bytes(): 9 | # https://github.com/pandas-dev/pandas/issues/38607 10 | # GH#49658 pre-2.0 Index called .values.astype(str) here, which effectively 11 | # did a .decode() on the bytes object. In 2.0 we go through 12 | # ensure_string_array which does f"{val}" 13 | idx = Index(["あ", b"a"], dtype="object") 14 | result = idx.astype(str) 15 | expected = Index(["あ", "a"], dtype="str") 16 | tm.assert_index_equal(result, expected) 17 | 18 | # while we're here, check that Series.astype behaves the same 19 | result = Series(idx).astype(str) 20 | expected = Series(expected, dtype="str") 21 | tm.assert_series_equal(result, expected) 22 | -------------------------------------------------------------------------------- /pandas/tests/indexes/test_subclass.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests involving custom Index subclasses 3 | """ 4 | 5 | import numpy as np 6 | 7 | from pandas import ( 8 | DataFrame, 9 | Index, 10 | ) 11 | import pandas._testing as tm 12 | 13 | 14 | class CustomIndex(Index): 15 | def __new__(cls, data, name=None): 16 | # assert that this index class cannot hold strings 17 | if any(isinstance(val, str) for val in data): 18 | raise TypeError("CustomIndex cannot hold strings") 19 | 20 | if name is None and hasattr(data, "name"): 21 | name = data.name 22 | data = np.array(data, dtype="O") 23 | 24 | return cls._simple_new(data, name) 25 | 26 | 27 | def test_insert_fallback_to_base_index(): 28 | # https://github.com/pandas-dev/pandas/issues/47071 29 | 30 | idx = CustomIndex([1, 2, 3]) 31 | result = idx.insert(0, "string") 32 | expected = Index(["string", 1, 2, 3], dtype=object) 33 | tm.assert_index_equal(result, expected) 34 | 35 | df = DataFrame( 36 | np.random.default_rng(2).standard_normal((2, 3)), 37 | columns=idx, 38 | index=Index([1, 2], name="string"), 39 | ) 40 | result = df.reset_index() 41 | tm.assert_index_equal(result.columns, expected) 42 | -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/timedeltas/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexes/timedeltas/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/methods/test_fillna.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | Index, 3 | NaT, 4 | Timedelta, 5 | TimedeltaIndex, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestFillNA: 11 | def test_fillna_timedelta(self): 12 | # GH#11343 13 | idx = TimedeltaIndex(["1 day", NaT, "3 day"]) 14 | 15 | exp = TimedeltaIndex(["1 day", "2 day", "3 day"]) 16 | tm.assert_index_equal(idx.fillna(Timedelta("2 day")), exp) 17 | 18 | exp = TimedeltaIndex(["1 day", "3 hour", "3 day"]) 19 | idx.fillna(Timedelta("3 hour")) 20 | 21 | exp = Index([Timedelta("1 day"), "x", Timedelta("3 day")], dtype=object) 22 | tm.assert_index_equal(idx.fillna("x"), exp) 23 | -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/methods/test_repeat.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | TimedeltaIndex, 5 | timedelta_range, 6 | ) 7 | import pandas._testing as tm 8 | 9 | 10 | class TestRepeat: 11 | def test_repeat(self): 12 | index = timedelta_range("1 days", periods=2, freq="D") 13 | exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"]) 14 | for res in [index.repeat(2), np.repeat(index, 2)]: 15 | tm.assert_index_equal(res, exp) 16 | assert res.freq is None 17 | 18 | index = TimedeltaIndex(["1 days", "NaT", "3 days"]) 19 | exp = TimedeltaIndex( 20 | [ 21 | "1 days", 22 | "1 days", 23 | "1 days", 24 | "NaT", 25 | "NaT", 26 | "NaT", 27 | "3 days", 28 | "3 days", 29 | "3 days", 30 | ] 31 | ) 32 | for res in [index.repeat(3), np.repeat(index, 3)]: 33 | tm.assert_index_equal(res, exp) 34 | assert res.freq is None 35 | -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/test_ops.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | TimedeltaIndex, 3 | timedelta_range, 4 | ) 5 | import pandas._testing as tm 6 | 7 | 8 | class TestTimedeltaIndexOps: 9 | def test_infer_freq(self, freq_sample): 10 | # GH#11018 11 | idx = timedelta_range("1", freq=freq_sample, periods=10) 12 | result = TimedeltaIndex(idx.asi8, freq="infer") 13 | tm.assert_index_equal(idx, result) 14 | assert result.freq == freq_sample 15 | -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/test_pickle.py: -------------------------------------------------------------------------------- 1 | from pandas import timedelta_range 2 | import pandas._testing as tm 3 | 4 | 5 | class TestPickle: 6 | def test_pickle_after_set_freq(self): 7 | tdi = timedelta_range("1 day", periods=4, freq="s") 8 | tdi = tdi._with_freq(None) 9 | 10 | res = tm.round_trip_pickle(tdi) 11 | tm.assert_index_equal(res, tdi) 12 | -------------------------------------------------------------------------------- /pandas/tests/indexes/timedeltas/test_searchsorted.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | TimedeltaIndex, 6 | Timestamp, 7 | ) 8 | import pandas._testing as tm 9 | 10 | 11 | class TestSearchSorted: 12 | def test_searchsorted_different_argument_classes(self, listlike_box): 13 | idx = TimedeltaIndex(["1 day", "2 days", "3 days"]) 14 | result = idx.searchsorted(listlike_box(idx)) 15 | expected = np.arange(len(idx), dtype=result.dtype) 16 | tm.assert_numpy_array_equal(result, expected) 17 | 18 | result = idx._data.searchsorted(listlike_box(idx)) 19 | tm.assert_numpy_array_equal(result, expected) 20 | 21 | @pytest.mark.parametrize( 22 | "arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2] 23 | ) 24 | def test_searchsorted_invalid_argument_dtype(self, arg): 25 | idx = TimedeltaIndex(["1 day", "2 days", "3 days"]) 26 | msg = "value should be a 'Timedelta', 'NaT', or array of those. Got" 27 | with pytest.raises(TypeError, match=msg): 28 | idx.searchsorted(arg) 29 | -------------------------------------------------------------------------------- /pandas/tests/indexing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexing/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexing/common.py: -------------------------------------------------------------------------------- 1 | """common utilities""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import ( 6 | Any, 7 | Literal, 8 | ) 9 | 10 | 11 | def _mklbl(prefix: str, n: int): 12 | return [f"{prefix}{i}" for i in range(n)] 13 | 14 | 15 | def check_indexing_smoketest_or_raises( 16 | obj, 17 | method: Literal["iloc", "loc"], 18 | key: Any, 19 | axes: Literal[0, 1] | None = None, 20 | fails=None, 21 | ) -> None: 22 | if axes is None: 23 | axes_list = [0, 1] 24 | else: 25 | assert axes in [0, 1] 26 | axes_list = [axes] 27 | 28 | for ax in axes_list: 29 | if ax < obj.ndim: 30 | # create a tuple accessor 31 | new_axes = [slice(None)] * obj.ndim 32 | new_axes[ax] = key 33 | axified = tuple(new_axes) 34 | try: 35 | getattr(obj, method).__getitem__(axified) 36 | except (IndexError, TypeError, KeyError) as detail: 37 | # if we are in fails, the ok, otherwise raise it 38 | if fails is not None: 39 | if isinstance(detail, fails): 40 | return 41 | raise 42 | -------------------------------------------------------------------------------- /pandas/tests/indexing/interval/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexing/interval/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexing/multiindex/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/indexing/multiindex/__init__.py -------------------------------------------------------------------------------- /pandas/tests/indexing/test_iat.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | DataFrame, 5 | Series, 6 | period_range, 7 | ) 8 | 9 | 10 | def test_iat(float_frame): 11 | for i, row in enumerate(float_frame.index): 12 | for j, col in enumerate(float_frame.columns): 13 | result = float_frame.iat[i, j] 14 | expected = float_frame.at[row, col] 15 | assert result == expected 16 | 17 | 18 | def test_iat_duplicate_columns(): 19 | # https://github.com/pandas-dev/pandas/issues/11754 20 | df = DataFrame([[1, 2]], columns=["x", "x"]) 21 | assert df.iat[0, 0] == 1 22 | 23 | 24 | def test_iat_getitem_series_with_period_index(): 25 | # GH#4390, iat incorrectly indexing 26 | index = period_range("1/1/2001", periods=10) 27 | ser = Series(np.random.default_rng(2).standard_normal(10), index=index) 28 | expected = ser[index[0]] 29 | result = ser.iat[0] 30 | assert expected == result 31 | -------------------------------------------------------------------------------- /pandas/tests/interchange/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/interchange/__init__.py -------------------------------------------------------------------------------- /pandas/tests/internals/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/internals/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/excel/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/excel/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/formats/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/formats/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/formats/style/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/formats/style/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/formats/style/test_exceptions.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | jinja2 = pytest.importorskip("jinja2") 4 | 5 | from pandas import ( 6 | DataFrame, 7 | MultiIndex, 8 | ) 9 | 10 | from pandas.io.formats.style import Styler 11 | 12 | 13 | @pytest.fixture 14 | def df(): 15 | return DataFrame( 16 | data=[[0, -0.609], [1, -1.228]], 17 | columns=["A", "B"], 18 | index=["x", "y"], 19 | ) 20 | 21 | 22 | @pytest.fixture 23 | def styler(df): 24 | return Styler(df, uuid_len=0) 25 | 26 | 27 | def test_concat_bad_columns(styler): 28 | msg = "`other.data` must have same columns as `Styler.data" 29 | with pytest.raises(ValueError, match=msg): 30 | styler.concat(DataFrame([[1, 2]]).style) 31 | 32 | 33 | def test_concat_bad_type(styler): 34 | msg = "`other` must be of type `Styler`" 35 | with pytest.raises(TypeError, match=msg): 36 | styler.concat(DataFrame([[1, 2]])) 37 | 38 | 39 | def test_concat_bad_index_levels(styler, df): 40 | df = df.copy() 41 | df.index = MultiIndex.from_tuples([(0, 0), (1, 1)]) 42 | msg = "number of index levels must be same in `other`" 43 | with pytest.raises(ValueError, match=msg): 44 | styler.concat(df.style) 45 | -------------------------------------------------------------------------------- /pandas/tests/io/json/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/json/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/json/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.fixture(params=["split", "records", "index", "columns", "values"]) 5 | def orient(request): 6 | """ 7 | Fixture for orients excluding the table format. 8 | """ 9 | return request.param 10 | -------------------------------------------------------------------------------- /pandas/tests/io/json/test_deprecated_kwargs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for the deprecated keyword arguments for `read_json`. 3 | """ 4 | 5 | from io import StringIO 6 | 7 | import pandas as pd 8 | import pandas._testing as tm 9 | 10 | from pandas.io.json import read_json 11 | 12 | 13 | def test_good_kwargs(): 14 | df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2]) 15 | 16 | with tm.assert_produces_warning(None): 17 | data1 = StringIO(df.to_json(orient="split")) 18 | tm.assert_frame_equal(df, read_json(data1, orient="split")) 19 | data2 = StringIO(df.to_json(orient="columns")) 20 | tm.assert_frame_equal(df, read_json(data2, orient="columns")) 21 | data3 = StringIO(df.to_json(orient="index")) 22 | tm.assert_frame_equal(df, read_json(data3, orient="index")) 23 | -------------------------------------------------------------------------------- /pandas/tests/io/parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/parser/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/parser/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/parser/common/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/parser/dtypes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/parser/dtypes/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/parser/usecols/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/parser/usecols/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/pytables/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/pytables/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/pytables/conftest.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | 3 | import pytest 4 | 5 | 6 | @pytest.fixture 7 | def setup_path(): 8 | """Fixture for setup path""" 9 | return f"tmp.__{uuid.uuid4()}__.h5" 10 | -------------------------------------------------------------------------------- /pandas/tests/io/pytables/test_pytables_missing.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas.util._test_decorators as td 4 | 5 | import pandas as pd 6 | import pandas._testing as tm 7 | 8 | 9 | @td.skip_if_installed("tables") 10 | def test_pytables_raises(): 11 | df = pd.DataFrame({"A": [1, 2]}) 12 | with pytest.raises(ImportError, match="tables"): 13 | with tm.ensure_clean("foo.h5") as path: 14 | df.to_hdf(path, key="df") 15 | -------------------------------------------------------------------------------- /pandas/tests/io/sas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/sas/__init__.py -------------------------------------------------------------------------------- /pandas/tests/io/sas/test_sas.py: -------------------------------------------------------------------------------- 1 | from io import StringIO 2 | 3 | import pytest 4 | 5 | from pandas import read_sas 6 | import pandas._testing as tm 7 | 8 | 9 | class TestSas: 10 | def test_sas_buffer_format(self): 11 | # see gh-14947 12 | b = StringIO("") 13 | 14 | msg = ( 15 | "If this is a buffer object rather than a string " 16 | "name, you must specify a format string" 17 | ) 18 | with pytest.raises(ValueError, match=msg): 19 | read_sas(b) 20 | 21 | def test_sas_read_no_format_or_extension(self): 22 | # see gh-24548 23 | msg = "unable to infer format of SAS file.+" 24 | with tm.ensure_clean("test_file_no_extension") as path: 25 | with pytest.raises(ValueError, match=msg): 26 | read_sas(path) 27 | 28 | 29 | def test_sas_archive(datapath): 30 | fname_uncompressed = datapath("io", "sas", "data", "airline.sas7bdat") 31 | df_uncompressed = read_sas(fname_uncompressed) 32 | fname_compressed = datapath("io", "sas", "data", "airline.sas7bdat.gz") 33 | df_compressed = read_sas(fname_compressed, format="sas7bdat") 34 | tm.assert_frame_equal(df_uncompressed, df_compressed) 35 | -------------------------------------------------------------------------------- /pandas/tests/io/test_s3.py: -------------------------------------------------------------------------------- 1 | from io import BytesIO 2 | 3 | import pytest 4 | 5 | from pandas import read_csv 6 | 7 | 8 | def test_streaming_s3_objects(): 9 | # GH17135 10 | # botocore gained iteration support in 1.10.47, can now be used in read_* 11 | pytest.importorskip("botocore", minversion="1.10.47") 12 | from botocore.response import StreamingBody 13 | 14 | data = [b"foo,bar,baz\n1,2,3\n4,5,6\n", b"just,the,header\n"] 15 | for el in data: 16 | body = StreamingBody(BytesIO(el), content_length=len(el)) 17 | read_csv(body) 18 | 19 | 20 | @pytest.mark.single_cpu 21 | def test_read_without_creds_from_pub_bucket(s3_public_bucket_with_data, s3so): 22 | # GH 34626 23 | pytest.importorskip("s3fs") 24 | result = read_csv( 25 | f"s3://{s3_public_bucket_with_data.name}/tips.csv", 26 | nrows=3, 27 | storage_options=s3so, 28 | ) 29 | assert len(result) == 3 30 | 31 | 32 | @pytest.mark.single_cpu 33 | def test_read_with_creds_from_pub_bucket(s3_public_bucket_with_data, s3so): 34 | # Ensure we can read from a public bucket with credentials 35 | # GH 34626 36 | pytest.importorskip("s3fs") 37 | df = read_csv( 38 | f"s3://{s3_public_bucket_with_data.name}/tips.csv", 39 | nrows=5, 40 | header=None, 41 | storage_options=s3so, 42 | ) 43 | assert len(df) == 5 44 | -------------------------------------------------------------------------------- /pandas/tests/io/xml/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/io/xml/__init__.py -------------------------------------------------------------------------------- /pandas/tests/libs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/libs/__init__.py -------------------------------------------------------------------------------- /pandas/tests/plotting/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/plotting/__init__.py -------------------------------------------------------------------------------- /pandas/tests/plotting/conftest.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | DataFrame, 6 | to_datetime, 7 | ) 8 | 9 | 10 | @pytest.fixture(autouse=True) 11 | def autouse_mpl_cleanup(mpl_cleanup): 12 | pass 13 | 14 | 15 | @pytest.fixture 16 | def hist_df(): 17 | n = 50 18 | rng = np.random.default_rng(10) 19 | gender = rng.choice(["Male", "Female"], size=n) 20 | classroom = rng.choice(["A", "B", "C"], size=n) 21 | 22 | hist_df = DataFrame( 23 | { 24 | "gender": gender, 25 | "classroom": classroom, 26 | "height": rng.normal(66, 4, size=n), 27 | "weight": rng.normal(161, 32, size=n), 28 | "category": rng.integers(4, size=n), 29 | "datetime": to_datetime( 30 | rng.integers( 31 | 812419200000000000, 32 | 819331200000000000, 33 | size=n, 34 | dtype=np.int64, 35 | ) 36 | ), 37 | } 38 | ) 39 | return hist_df 40 | -------------------------------------------------------------------------------- /pandas/tests/plotting/frame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/plotting/frame/__init__.py -------------------------------------------------------------------------------- /pandas/tests/reductions/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for reductions where we want to test for matching behavior across 3 | Array, Index, Series, and DataFrame methods. 4 | """ 5 | -------------------------------------------------------------------------------- /pandas/tests/resample/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/resample/__init__.py -------------------------------------------------------------------------------- /pandas/tests/resample/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | # The various methods we support 4 | downsample_methods = [ 5 | "min", 6 | "max", 7 | "first", 8 | "last", 9 | "sum", 10 | "mean", 11 | "sem", 12 | "median", 13 | "prod", 14 | "var", 15 | "std", 16 | "ohlc", 17 | "quantile", 18 | ] 19 | upsample_methods = ["count", "size"] 20 | series_methods = ["nunique"] 21 | resample_methods = downsample_methods + upsample_methods + series_methods 22 | 23 | 24 | @pytest.fixture(params=downsample_methods) 25 | def downsample_method(request): 26 | """Fixture for parametrization of Grouper downsample methods.""" 27 | return request.param 28 | 29 | 30 | @pytest.fixture(params=resample_methods) 31 | def resample_method(request): 32 | """Fixture for parametrization of Grouper resample methods.""" 33 | return request.param 34 | -------------------------------------------------------------------------------- /pandas/tests/reshape/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/reshape/__init__.py -------------------------------------------------------------------------------- /pandas/tests/reshape/concat/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/reshape/concat/__init__.py -------------------------------------------------------------------------------- /pandas/tests/reshape/merge/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/reshape/merge/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/interval/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/interval/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/interval/test_formats.py: -------------------------------------------------------------------------------- 1 | from pandas import Interval 2 | 3 | 4 | def test_interval_repr(): 5 | interval = Interval(0, 1) 6 | assert repr(interval) == "Interval(0, 1, closed='right')" 7 | assert str(interval) == "(0, 1]" 8 | 9 | interval_left = Interval(0, 1, closed="left") 10 | assert repr(interval_left) == "Interval(0, 1, closed='left')" 11 | assert str(interval_left) == "[0, 1)" 12 | -------------------------------------------------------------------------------- /pandas/tests/scalar/period/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/period/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/timedelta/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/timedelta/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/timedelta/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/timedelta/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/timestamp/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/methods/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/scalar/timestamp/methods/__init__.py -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/methods/test_normalize.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas._libs.tslibs import Timestamp 4 | from pandas._libs.tslibs.dtypes import NpyDatetimeUnit 5 | 6 | 7 | class TestTimestampNormalize: 8 | @pytest.mark.parametrize("arg", ["2013-11-30", "2013-11-30 12:00:00"]) 9 | def test_normalize(self, tz_naive_fixture, arg, unit): 10 | tz = tz_naive_fixture 11 | ts = Timestamp(arg, tz=tz).as_unit(unit) 12 | result = ts.normalize() 13 | expected = Timestamp("2013-11-30", tz=tz) 14 | assert result == expected 15 | assert result._creso == getattr(NpyDatetimeUnit, f"NPY_FR_{unit}").value 16 | 17 | def test_normalize_pre_epoch_dates(self): 18 | # GH: 36294 19 | result = Timestamp("1969-01-01 09:00:00").normalize() 20 | expected = Timestamp("1969-01-01 00:00:00") 21 | assert result == expected 22 | -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/methods/test_timestamp_method.py: -------------------------------------------------------------------------------- 1 | # NB: This is for the Timestamp.timestamp *method* specifically, not 2 | # the Timestamp class in general. 3 | from datetime import timezone 4 | 5 | import pytest 6 | 7 | from pandas._libs.tslibs import Timestamp 8 | from pandas.compat import WASM 9 | import pandas.util._test_decorators as td 10 | 11 | import pandas._testing as tm 12 | 13 | 14 | class TestTimestampMethod: 15 | @td.skip_if_windows 16 | @pytest.mark.skipif(WASM, reason="tzset is not available on WASM") 17 | def test_timestamp(self, fixed_now_ts): 18 | # GH#17329 19 | # tz-naive --> treat it as if it were UTC for purposes of timestamp() 20 | ts = fixed_now_ts 21 | uts = ts.replace(tzinfo=timezone.utc) 22 | assert ts.timestamp() == uts.timestamp() 23 | 24 | tsc = Timestamp("2014-10-11 11:00:01.12345678", tz="US/Central") 25 | utsc = tsc.tz_convert("UTC") 26 | 27 | # utsc is a different representation of the same time 28 | assert tsc.timestamp() == utsc.timestamp() 29 | 30 | # datetime.timestamp() converts in the local timezone 31 | with tm.set_timezone("UTC"): 32 | # should agree with datetime.timestamp method 33 | dt = ts.to_pydatetime() 34 | assert dt.timestamp() == ts.timestamp() 35 | -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/methods/test_to_julian_date.py: -------------------------------------------------------------------------------- 1 | from pandas import Timestamp 2 | 3 | 4 | class TestTimestampToJulianDate: 5 | def test_compare_1700(self): 6 | ts = Timestamp("1700-06-23") 7 | res = ts.to_julian_date() 8 | assert res == 2_342_145.5 9 | 10 | def test_compare_2000(self): 11 | ts = Timestamp("2000-04-12") 12 | res = ts.to_julian_date() 13 | assert res == 2_451_646.5 14 | 15 | def test_compare_2100(self): 16 | ts = Timestamp("2100-08-12") 17 | res = ts.to_julian_date() 18 | assert res == 2_488_292.5 19 | 20 | def test_compare_hour01(self): 21 | ts = Timestamp("2000-08-12T01:00:00") 22 | res = ts.to_julian_date() 23 | assert res == 2_451_768.5416666666666666 24 | 25 | def test_compare_hour13(self): 26 | ts = Timestamp("2000-08-12T13:00:00") 27 | res = ts.to_julian_date() 28 | assert res == 2_451_769.0416666666666666 29 | -------------------------------------------------------------------------------- /pandas/tests/scalar/timestamp/test_timezones.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for Timestamp timezone-related methods 3 | """ 4 | 5 | from datetime import datetime 6 | 7 | from pandas._libs.tslibs import timezones 8 | 9 | from pandas import Timestamp 10 | 11 | 12 | class TestTimestampTZOperations: 13 | # ------------------------------------------------------------------ 14 | 15 | def test_timestamp_timetz_equivalent_with_datetime_tz(self, tz_naive_fixture): 16 | # GH21358 17 | tz = timezones.maybe_get_tz(tz_naive_fixture) 18 | 19 | stamp = Timestamp("2018-06-04 10:20:30", tz=tz) 20 | _datetime = datetime(2018, 6, 4, hour=10, minute=20, second=30, tzinfo=tz) 21 | 22 | result = stamp.timetz() 23 | expected = _datetime.timetz() 24 | 25 | assert result == expected 26 | -------------------------------------------------------------------------------- /pandas/tests/series/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/series/__init__.py -------------------------------------------------------------------------------- /pandas/tests/series/accessors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/series/accessors/__init__.py -------------------------------------------------------------------------------- /pandas/tests/series/accessors/test_sparse_accessor.py: -------------------------------------------------------------------------------- 1 | from pandas import Series 2 | 3 | 4 | class TestSparseAccessor: 5 | def test_sparse_accessor_updates_on_inplace(self): 6 | ser = Series([1, 1, 2, 3], dtype="Sparse[int]") 7 | return_value = ser.drop([0, 1], inplace=True) 8 | assert return_value is None 9 | assert ser.sparse.density == 1.0 10 | -------------------------------------------------------------------------------- /pandas/tests/series/accessors/test_str_accessor.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import Series 4 | import pandas._testing as tm 5 | 6 | 7 | class TestStrAccessor: 8 | def test_str_attribute(self): 9 | # GH#9068 10 | methods = ["strip", "rstrip", "lstrip"] 11 | ser = Series([" jack", "jill ", " jesse ", "frank"]) 12 | for method in methods: 13 | expected = Series([getattr(str, method)(x) for x in ser.values]) 14 | tm.assert_series_equal(getattr(Series.str, method)(ser.str), expected) 15 | 16 | # str accessor only valid with string values 17 | ser = Series(range(5)) 18 | msg = "Can only use .str accessor with string values, not integer" 19 | with pytest.raises(AttributeError, match=msg): 20 | ser.str.repeat(2) 21 | 22 | def test_str_accessor_updates_on_inplace(self): 23 | ser = Series(list("abc")) 24 | return_value = ser.drop([0], inplace=True) 25 | assert return_value is None 26 | assert len(ser.str.lower()) == 2 27 | -------------------------------------------------------------------------------- /pandas/tests/series/indexing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/series/indexing/__init__.py -------------------------------------------------------------------------------- /pandas/tests/series/methods/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Test files dedicated to individual (stand-alone) Series methods 3 | 4 | Ideally these files/tests should correspond 1-to-1 with tests.frame.methods 5 | 6 | These may also present opportunities for sharing/de-duplicating test code. 7 | """ 8 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_autocorr.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class TestAutoCorr: 5 | def test_autocorr(self, datetime_series): 6 | # Just run the function 7 | corr1 = datetime_series.autocorr() 8 | 9 | # Now run it with the lag parameter 10 | corr2 = datetime_series.autocorr(lag=1) 11 | 12 | # corr() with lag needs Series of at least length 2 13 | if len(datetime_series) <= 2: 14 | assert np.isnan(corr1) 15 | assert np.isnan(corr2) 16 | else: 17 | assert corr1 == corr2 18 | 19 | # Choose a random lag between 1 and length of Series - 2 20 | # and compare the result with the Series corr() function 21 | n = 1 + np.random.default_rng(2).integers(max(1, len(datetime_series) - 2)) 22 | corr1 = datetime_series.corr(datetime_series.shift(n)) 23 | corr2 = datetime_series.autocorr(lag=n) 24 | 25 | # corr() with lag needs Series of at least length 2 26 | if len(datetime_series) <= 2: 27 | assert np.isnan(corr1) 28 | assert np.isnan(corr2) 29 | else: 30 | assert corr1 == corr2 31 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_combine.py: -------------------------------------------------------------------------------- 1 | from pandas import Series 2 | import pandas._testing as tm 3 | 4 | 5 | class TestCombine: 6 | def test_combine_scalar(self): 7 | # GH#21248 8 | # Note - combine() with another Series is tested elsewhere because 9 | # it is used when testing operators 10 | ser = Series([i * 10 for i in range(5)]) 11 | result = ser.combine(3, lambda x, y: x + y) 12 | expected = Series([i * 10 + 3 for i in range(5)]) 13 | tm.assert_series_equal(result, expected) 14 | 15 | result = ser.combine(22, lambda x, y: min(x, y)) 16 | expected = Series([min(i * 10, 22) for i in range(5)]) 17 | tm.assert_series_equal(result, expected) 18 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_count.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | Categorical, 5 | Series, 6 | ) 7 | 8 | 9 | class TestSeriesCount: 10 | def test_count(self, datetime_series): 11 | assert datetime_series.count() == len(datetime_series) 12 | 13 | datetime_series[::2] = np.nan 14 | 15 | assert datetime_series.count() == np.isfinite(datetime_series).sum() 16 | 17 | def test_count_categorical(self): 18 | ser = Series( 19 | Categorical( 20 | [np.nan, 1, 2, np.nan], categories=[5, 4, 3, 2, 1], ordered=True 21 | ) 22 | ) 23 | result = ser.count() 24 | assert result == 2 25 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_dtypes.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class TestSeriesDtypes: 5 | def test_dtype(self, datetime_series): 6 | assert datetime_series.dtype == np.dtype("float64") 7 | assert datetime_series.dtypes == np.dtype("float64") 8 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_get_numeric_data.py: -------------------------------------------------------------------------------- 1 | from pandas import ( 2 | Series, 3 | date_range, 4 | ) 5 | import pandas._testing as tm 6 | 7 | 8 | class TestGetNumericData: 9 | def test_get_numeric_data_preserve_dtype(self): 10 | # get the numeric data 11 | obj = Series([1, 2, 3]) 12 | result = obj._get_numeric_data() 13 | tm.assert_series_equal(result, obj) 14 | 15 | # returned object is a shallow copy 16 | result.iloc[0] = 0 17 | assert obj.iloc[0] == 1 18 | 19 | obj = Series([1, "2", 3.0]) 20 | result = obj._get_numeric_data() 21 | expected = Series([], dtype=object) 22 | tm.assert_series_equal(result, expected) 23 | 24 | obj = Series([True, False, True]) 25 | result = obj._get_numeric_data() 26 | tm.assert_series_equal(result, obj) 27 | 28 | obj = Series(date_range("20130101", periods=3)) 29 | result = obj._get_numeric_data() 30 | expected = Series([], dtype="M8[ns]") 31 | tm.assert_series_equal(result, expected) 32 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_head_tail.py: -------------------------------------------------------------------------------- 1 | import pandas._testing as tm 2 | 3 | 4 | def test_head_tail(string_series): 5 | tm.assert_series_equal(string_series.head(), string_series[:5]) 6 | tm.assert_series_equal(string_series.head(0), string_series[0:0]) 7 | tm.assert_series_equal(string_series.tail(), string_series[-5:]) 8 | tm.assert_series_equal(string_series.tail(0), string_series[0:0]) 9 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_is_monotonic.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | Series, 5 | date_range, 6 | ) 7 | 8 | 9 | class TestIsMonotonic: 10 | def test_is_monotonic_numeric(self): 11 | ser = Series(np.random.default_rng(2).integers(0, 10, size=1000)) 12 | assert not ser.is_monotonic_increasing 13 | ser = Series(np.arange(1000)) 14 | assert ser.is_monotonic_increasing is True 15 | assert ser.is_monotonic_increasing is True 16 | ser = Series(np.arange(1000, 0, -1)) 17 | assert ser.is_monotonic_decreasing is True 18 | 19 | def test_is_monotonic_dt64(self): 20 | ser = Series(date_range("20130101", periods=10)) 21 | assert ser.is_monotonic_increasing is True 22 | assert ser.is_monotonic_increasing is True 23 | 24 | ser = Series(list(reversed(ser))) 25 | assert ser.is_monotonic_increasing is False 26 | assert ser.is_monotonic_decreasing is True 27 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_is_unique.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import Series 5 | 6 | 7 | @pytest.mark.parametrize( 8 | "data, expected", 9 | [ 10 | (np.random.default_rng(2).integers(0, 10, size=1000), False), 11 | (np.arange(1000), True), 12 | ([], True), 13 | ([np.nan], True), 14 | (["foo", "bar", np.nan], True), 15 | (["foo", "foo", np.nan], False), 16 | (["foo", "bar", np.nan, np.nan], False), 17 | ], 18 | ) 19 | def test_is_unique(data, expected): 20 | # GH#11946 / GH#25180 21 | ser = Series(data) 22 | assert ser.is_unique is expected 23 | 24 | 25 | def test_is_unique_class_ne(capsys): 26 | # GH#20661 27 | class Foo: 28 | def __init__(self, val) -> None: 29 | self._value = val 30 | 31 | def __ne__(self, other): 32 | raise Exception("NEQ not supported") 33 | 34 | with capsys.disabled(): 35 | li = [Foo(i) for i in range(5)] 36 | ser = Series(li, index=list(range(5))) 37 | 38 | ser.is_unique 39 | captured = capsys.readouterr() 40 | assert len(captured.err) == 0 41 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_isna.py: -------------------------------------------------------------------------------- 1 | """ 2 | We also test Series.notna in this file. 3 | """ 4 | 5 | import numpy as np 6 | 7 | from pandas import ( 8 | Period, 9 | Series, 10 | ) 11 | import pandas._testing as tm 12 | 13 | 14 | class TestIsna: 15 | def test_isna_period_dtype(self): 16 | # GH#13737 17 | ser = Series([Period("2011-01", freq="M"), Period("NaT", freq="M")]) 18 | 19 | expected = Series([False, True]) 20 | 21 | result = ser.isna() 22 | tm.assert_series_equal(result, expected) 23 | 24 | result = ser.notna() 25 | tm.assert_series_equal(result, ~expected) 26 | 27 | def test_isna(self): 28 | ser = Series([0, 5.4, 3, np.nan, -0.001]) 29 | expected = Series([False, False, False, True, False]) 30 | tm.assert_series_equal(ser.isna(), expected) 31 | tm.assert_series_equal(ser.notna(), ~expected) 32 | 33 | ser = Series(["hi", "", np.nan]) 34 | expected = Series([False, False, True]) 35 | tm.assert_series_equal(ser.isna(), expected) 36 | tm.assert_series_equal(ser.notna(), ~expected) 37 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_nunique.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas import ( 4 | Categorical, 5 | Series, 6 | ) 7 | 8 | 9 | def test_nunique(): 10 | # basics.rst doc example 11 | series = Series(np.random.default_rng(2).standard_normal(500)) 12 | series[20:500] = np.nan 13 | series[10:20] = 5000 14 | result = series.nunique() 15 | assert result == 11 16 | 17 | 18 | def test_nunique_categorical(): 19 | # GH#18051 20 | ser = Series(Categorical([])) 21 | assert ser.nunique() == 0 22 | 23 | ser = Series(Categorical([np.nan])) 24 | assert ser.nunique() == 0 25 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_pop.py: -------------------------------------------------------------------------------- 1 | from pandas import Series 2 | import pandas._testing as tm 3 | 4 | 5 | def test_pop(): 6 | # GH#6600 7 | ser = Series([0, 4, 0], index=["A", "B", "C"], name=4) 8 | 9 | result = ser.pop("B") 10 | assert result == 4 11 | 12 | expected = Series([0, 0], index=["A", "C"], name=4) 13 | tm.assert_series_equal(ser, expected) 14 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_set_name.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | from pandas import Series 4 | 5 | 6 | class TestSetName: 7 | def test_set_name(self): 8 | ser = Series([1, 2, 3]) 9 | ser2 = ser._set_name("foo") 10 | assert ser2.name == "foo" 11 | assert ser.name is None 12 | assert ser is not ser2 13 | 14 | def test_set_name_attribute(self): 15 | ser = Series([1, 2, 3]) 16 | ser2 = Series([1, 2, 3], name="bar") 17 | for name in [7, 7.0, "name", datetime(2001, 1, 1), (1,), "\u05d0"]: 18 | ser.name = name 19 | assert ser.name == name 20 | ser2.name = name 21 | assert ser2.name == name 22 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_size.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas import Series 4 | 5 | 6 | @pytest.mark.parametrize( 7 | "data, index, expected", 8 | [ 9 | ([1, 2, 3], None, 3), 10 | ({"a": 1, "b": 2, "c": 3}, None, 3), 11 | ([1, 2, 3], ["x", "y", "z"], 3), 12 | ([1, 2, 3, 4, 5], ["x", "y", "z", "w", "n"], 5), 13 | ([1, 2, 3, 4], ["x", "y", "z", "w"], 4), 14 | ], 15 | ) 16 | def test_series(data, index, expected): 17 | # GH#52897 18 | ser = Series(data, index=index) 19 | assert ser.size == expected 20 | assert isinstance(ser.size, int) 21 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_to_dict.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | from pandas import Series 7 | import pandas._testing as tm 8 | 9 | 10 | class TestSeriesToDict: 11 | @pytest.mark.parametrize( 12 | "mapping", (dict, collections.defaultdict(list), collections.OrderedDict) 13 | ) 14 | def test_to_dict(self, mapping, datetime_series): 15 | # GH#16122 16 | result = Series(datetime_series.to_dict(into=mapping), name="ts") 17 | expected = datetime_series.copy() 18 | expected.index = expected.index._with_freq(None) 19 | tm.assert_series_equal(result, expected) 20 | 21 | from_method = Series(datetime_series.to_dict(into=collections.Counter)) 22 | from_constructor = Series(collections.Counter(datetime_series.items())) 23 | tm.assert_series_equal(from_method, from_constructor) 24 | 25 | @pytest.mark.parametrize( 26 | "input", 27 | ( 28 | {"a": np.int64(64), "b": 10}, 29 | {"a": np.int64(64), "b": 10, "c": "ABC"}, 30 | {"a": np.uint64(64), "b": 10, "c": "ABC"}, 31 | ), 32 | ) 33 | def test_to_dict_return_types(self, input): 34 | # GH25969 35 | 36 | d = Series(input).to_dict() 37 | assert isinstance(d["a"], int) 38 | assert isinstance(d["b"], int) 39 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_tolist.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas.util._test_decorators as td 4 | 5 | from pandas import ( 6 | Interval, 7 | Period, 8 | Series, 9 | Timedelta, 10 | Timestamp, 11 | ) 12 | 13 | 14 | @pytest.mark.parametrize( 15 | "values, dtype, expected_dtype", 16 | ( 17 | ([1], "int64", int), 18 | ([1], "Int64", int), 19 | ([1.0], "float64", float), 20 | ([1.0], "Float64", float), 21 | (["abc"], "object", str), 22 | (["abc"], "string", str), 23 | ([Interval(1, 3)], "interval", Interval), 24 | ([Period("2000-01-01", "D")], "period[D]", Period), 25 | ([Timedelta(days=1)], "timedelta64[ns]", Timedelta), 26 | ([Timestamp("2000-01-01")], "datetime64[ns]", Timestamp), 27 | pytest.param([1], "int64[pyarrow]", int, marks=td.skip_if_no("pyarrow")), 28 | pytest.param([1.0], "float64[pyarrow]", float, marks=td.skip_if_no("pyarrow")), 29 | pytest.param(["abc"], "string[pyarrow]", str, marks=td.skip_if_no("pyarrow")), 30 | ), 31 | ) 32 | def test_tolist_scalar_dtype(values, dtype, expected_dtype): 33 | # GH49890 34 | ser = Series(values, dtype=dtype) 35 | result_dtype = type(ser.tolist()[0]) 36 | assert result_dtype == expected_dtype 37 | -------------------------------------------------------------------------------- /pandas/tests/series/methods/test_values.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas import ( 5 | IntervalIndex, 6 | Series, 7 | period_range, 8 | ) 9 | import pandas._testing as tm 10 | 11 | 12 | class TestValues: 13 | @pytest.mark.parametrize( 14 | "data", 15 | [ 16 | period_range("2000", periods=4), 17 | IntervalIndex.from_breaks([1, 2, 3, 4]), 18 | ], 19 | ) 20 | def test_values_object_extension_dtypes(self, data): 21 | # https://github.com/pandas-dev/pandas/issues/23995 22 | result = Series(data).values 23 | expected = np.array(data.astype(object)) 24 | tm.assert_numpy_array_equal(result, expected) 25 | 26 | def test_values(self, datetime_series): 27 | tm.assert_almost_equal( 28 | datetime_series.values, list(datetime_series), check_dtype=False 29 | ) 30 | -------------------------------------------------------------------------------- /pandas/tests/series/test_npfuncs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for np.foo applied to Series, not necessarily ufuncs. 3 | """ 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | import pandas.util._test_decorators as td 9 | 10 | from pandas import Series 11 | import pandas._testing as tm 12 | 13 | 14 | class TestPtp: 15 | def test_ptp(self): 16 | # GH#21614 17 | N = 1000 18 | arr = np.random.default_rng(2).standard_normal(N) 19 | ser = Series(arr) 20 | assert np.ptp(ser) == np.ptp(arr) 21 | 22 | 23 | def test_numpy_unique(datetime_series): 24 | # it works! 25 | np.unique(datetime_series) 26 | 27 | 28 | @pytest.mark.parametrize("index", [["a", "b", "c", "d", "e"], None]) 29 | def test_numpy_argwhere(index): 30 | # GH#35331 31 | 32 | s = Series(range(5), index=index, dtype=np.int64) 33 | 34 | result = np.argwhere(s > 2).astype(np.int64) 35 | expected = np.array([[3], [4]], dtype=np.int64) 36 | 37 | tm.assert_numpy_array_equal(result, expected) 38 | 39 | 40 | @td.skip_if_no("pyarrow") 41 | def test_log_arrow_backed_missing_value(): 42 | # GH#56285 43 | ser = Series([1, 2, None], dtype="float64[pyarrow]") 44 | result = np.log(ser) 45 | expected = np.log(Series([1, 2, None], dtype="float64")) 46 | tm.assert_series_equal(result, expected) 47 | -------------------------------------------------------------------------------- /pandas/tests/series/test_validate.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.mark.parametrize( 5 | "func", 6 | [ 7 | "reset_index", 8 | "_set_name", 9 | "sort_values", 10 | "sort_index", 11 | "rename", 12 | "dropna", 13 | "drop_duplicates", 14 | ], 15 | ) 16 | @pytest.mark.parametrize("inplace", [1, "True", [1, 2, 3], 5.0]) 17 | def test_validate_bool_args(string_series, func, inplace): 18 | """Tests for error handling related to data types of method arguments.""" 19 | msg = 'For argument "inplace" expected type bool' 20 | kwargs = {"inplace": inplace} 21 | 22 | if func == "_set_name": 23 | kwargs["name"] = "hello" 24 | 25 | with pytest.raises(ValueError, match=msg): 26 | getattr(string_series, func)(**kwargs) 27 | -------------------------------------------------------------------------------- /pandas/tests/strings/__init__.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import pandas as pd 4 | 5 | 6 | def is_object_or_nan_string_dtype(dtype): 7 | """ 8 | Check if string-like dtype is following NaN semantics, i.e. is object 9 | dtype or a NaN-variant of the StringDtype. 10 | """ 11 | return (isinstance(dtype, np.dtype) and dtype == "object") or ( 12 | dtype.na_value is np.nan 13 | ) 14 | 15 | 16 | def _convert_na_value(ser, expected): 17 | if ser.dtype != object: 18 | if ser.dtype.na_value is np.nan: 19 | expected = expected.fillna(np.nan) 20 | else: 21 | # GH#18463 22 | expected = expected.fillna(pd.NA) 23 | return expected 24 | -------------------------------------------------------------------------------- /pandas/tests/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tools/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tseries/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tseries/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tseries/frequencies/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tseries/frequencies/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tseries/frequencies/test_frequencies.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas._libs.tslibs import offsets 4 | 5 | from pandas.tseries.frequencies import ( 6 | is_subperiod, 7 | is_superperiod, 8 | ) 9 | 10 | 11 | @pytest.mark.parametrize( 12 | "p1,p2,expected", 13 | [ 14 | # Input validation. 15 | (offsets.MonthEnd(), None, False), 16 | (offsets.YearEnd(), None, False), 17 | (None, offsets.YearEnd(), False), 18 | (None, offsets.MonthEnd(), False), 19 | (None, None, False), 20 | (offsets.YearEnd(), offsets.MonthEnd(), True), 21 | (offsets.Hour(), offsets.Minute(), True), 22 | (offsets.Second(), offsets.Milli(), True), 23 | (offsets.Milli(), offsets.Micro(), True), 24 | (offsets.Micro(), offsets.Nano(), True), 25 | ], 26 | ) 27 | def test_super_sub_symmetry(p1, p2, expected): 28 | assert is_superperiod(p1, p2) is expected 29 | assert is_subperiod(p2, p1) is expected 30 | -------------------------------------------------------------------------------- /pandas/tests/tseries/holiday/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tseries/holiday/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tseries/offsets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tseries/offsets/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tseries/offsets/common.py: -------------------------------------------------------------------------------- 1 | """ 2 | Assertion helpers and base class for offsets tests 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | 8 | def assert_offset_equal(offset, base, expected): 9 | actual = offset + base 10 | actual_swapped = base + offset 11 | actual_apply = offset._apply(base) 12 | try: 13 | assert actual == expected 14 | assert actual_swapped == expected 15 | assert actual_apply == expected 16 | except AssertionError as err: 17 | raise AssertionError( 18 | f"\nExpected: {expected}\nActual: {actual}\nFor Offset: {offset})" 19 | f"\nAt Date: {base}" 20 | ) from err 21 | 22 | 23 | def assert_is_on_offset(offset, date, expected): 24 | actual = offset.is_on_offset(date) 25 | assert actual == expected, ( 26 | f"\nExpected: {expected}\nActual: {actual}\nFor Offset: {offset})" 27 | f"\nAt Date: {date}" 28 | ) 29 | 30 | 31 | class WeekDay: 32 | MON = 0 33 | TUE = 1 34 | WED = 2 35 | THU = 3 36 | FRI = 4 37 | SAT = 5 38 | SUN = 6 39 | -------------------------------------------------------------------------------- /pandas/tests/tseries/offsets/test_easter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for the following offsets: 3 | - Easter 4 | """ 5 | 6 | from __future__ import annotations 7 | 8 | from datetime import datetime 9 | 10 | import pytest 11 | 12 | from pandas.tests.tseries.offsets.common import assert_offset_equal 13 | 14 | from pandas.tseries.offsets import Easter 15 | 16 | 17 | class TestEaster: 18 | @pytest.mark.parametrize( 19 | "offset,date,expected", 20 | [ 21 | (Easter(), datetime(2010, 1, 1), datetime(2010, 4, 4)), 22 | (Easter(), datetime(2010, 4, 5), datetime(2011, 4, 24)), 23 | (Easter(2), datetime(2010, 1, 1), datetime(2011, 4, 24)), 24 | (Easter(), datetime(2010, 4, 4), datetime(2011, 4, 24)), 25 | (Easter(2), datetime(2010, 4, 4), datetime(2012, 4, 8)), 26 | (-Easter(), datetime(2011, 1, 1), datetime(2010, 4, 4)), 27 | (-Easter(), datetime(2010, 4, 5), datetime(2010, 4, 4)), 28 | (-Easter(2), datetime(2011, 1, 1), datetime(2009, 4, 12)), 29 | (-Easter(), datetime(2010, 4, 4), datetime(2009, 4, 12)), 30 | (-Easter(2), datetime(2010, 4, 4), datetime(2008, 3, 23)), 31 | ], 32 | ) 33 | def test_offset(self, offset, date, expected): 34 | assert_offset_equal(offset, date, expected) 35 | -------------------------------------------------------------------------------- /pandas/tests/tslibs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/tslibs/__init__.py -------------------------------------------------------------------------------- /pandas/tests/tslibs/test_libfrequencies.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pandas._libs.tslibs.parsing import get_rule_month 4 | 5 | from pandas.tseries import offsets 6 | 7 | 8 | @pytest.mark.parametrize( 9 | "obj,expected", 10 | [ 11 | ("W", "DEC"), 12 | (offsets.Week().freqstr, "DEC"), 13 | ("D", "DEC"), 14 | (offsets.Day().freqstr, "DEC"), 15 | ("Q", "DEC"), 16 | (offsets.QuarterEnd(startingMonth=12).freqstr, "DEC"), 17 | ("Q-JAN", "JAN"), 18 | (offsets.QuarterEnd(startingMonth=1).freqstr, "JAN"), 19 | ("Y-DEC", "DEC"), 20 | (offsets.YearEnd().freqstr, "DEC"), 21 | ("Y-MAY", "MAY"), 22 | (offsets.YearEnd(month=5).freqstr, "MAY"), 23 | ], 24 | ) 25 | def test_get_rule_month(obj, expected): 26 | result = get_rule_month(obj) 27 | assert result == expected 28 | -------------------------------------------------------------------------------- /pandas/tests/tslibs/test_npy_units.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pandas._libs.tslibs.dtypes import abbrev_to_npy_unit 4 | from pandas._libs.tslibs.vectorized import is_date_array_normalized 5 | 6 | # a datetime64 ndarray which *is* normalized 7 | day_arr = np.arange(10, dtype="i8").view("M8[D]") 8 | 9 | 10 | class TestIsDateArrayNormalized: 11 | def test_is_date_array_normalized_day(self): 12 | arr = day_arr 13 | abbrev = "D" 14 | unit = abbrev_to_npy_unit(abbrev) 15 | result = is_date_array_normalized(arr.view("i8"), None, unit) 16 | assert result is True 17 | 18 | def test_is_date_array_normalized_seconds(self): 19 | abbrev = "s" 20 | arr = day_arr.astype(f"M8[{abbrev}]") 21 | unit = abbrev_to_npy_unit(abbrev) 22 | result = is_date_array_normalized(arr.view("i8"), None, unit) 23 | assert result is True 24 | 25 | arr[0] += np.timedelta64(1, abbrev) 26 | result2 = is_date_array_normalized(arr.view("i8"), None, unit) 27 | assert result2 is False 28 | -------------------------------------------------------------------------------- /pandas/tests/tslibs/test_tzconversion.py: -------------------------------------------------------------------------------- 1 | import zoneinfo 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | from pandas._libs.tslibs.tzconversion import tz_localize_to_utc 7 | 8 | 9 | class TestTZLocalizeToUTC: 10 | def test_tz_localize_to_utc_ambiguous_infer(self): 11 | # val is a timestamp that is ambiguous when localized to US/Eastern 12 | val = 1_320_541_200_000_000_000 13 | vals = np.array([val, val - 1, val], dtype=np.int64) 14 | 15 | with pytest.raises(ValueError, match="2011-11-06 01:00:00"): 16 | tz_localize_to_utc(vals, zoneinfo.ZoneInfo("US/Eastern"), ambiguous="infer") 17 | 18 | with pytest.raises(ValueError, match="are no repeated times"): 19 | tz_localize_to_utc( 20 | vals[:1], zoneinfo.ZoneInfo("US/Eastern"), ambiguous="infer" 21 | ) 22 | 23 | vals[1] += 1 24 | msg = "There are 2 dst switches when there should only be 1" 25 | with pytest.raises(ValueError, match=msg): 26 | tz_localize_to_utc(vals, zoneinfo.ZoneInfo("US/Eastern"), ambiguous="infer") 27 | -------------------------------------------------------------------------------- /pandas/tests/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/util/__init__.py -------------------------------------------------------------------------------- /pandas/tests/util/test_assert_attr_equal.py: -------------------------------------------------------------------------------- 1 | from types import SimpleNamespace 2 | 3 | import pytest 4 | 5 | from pandas.core.dtypes.common import is_float 6 | 7 | import pandas._testing as tm 8 | 9 | 10 | def test_assert_attr_equal(nulls_fixture): 11 | obj = SimpleNamespace() 12 | obj.na_value = nulls_fixture 13 | tm.assert_attr_equal("na_value", obj, obj) 14 | 15 | 16 | def test_assert_attr_equal_different_nulls(nulls_fixture, nulls_fixture2): 17 | obj = SimpleNamespace() 18 | obj.na_value = nulls_fixture 19 | 20 | obj2 = SimpleNamespace() 21 | obj2.na_value = nulls_fixture2 22 | 23 | if nulls_fixture is nulls_fixture2: 24 | tm.assert_attr_equal("na_value", obj, obj2) 25 | elif is_float(nulls_fixture) and is_float(nulls_fixture2): 26 | # we consider float("nan") and np.float64("nan") to be equivalent 27 | tm.assert_attr_equal("na_value", obj, obj2) 28 | elif type(nulls_fixture) is type(nulls_fixture2): 29 | # e.g. Decimal("NaN") 30 | tm.assert_attr_equal("na_value", obj, obj2) 31 | else: 32 | with pytest.raises(AssertionError, match='"na_value" are different'): 33 | tm.assert_attr_equal("na_value", obj, obj2) 34 | -------------------------------------------------------------------------------- /pandas/tests/util/test_numba.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | import pandas.util._test_decorators as td 4 | 5 | from pandas import option_context 6 | 7 | 8 | @td.skip_if_installed("numba") 9 | def test_numba_not_installed_option_context(): 10 | with pytest.raises(ImportError, match="Missing optional"): 11 | with option_context("compute.use_numba", True): 12 | pass 13 | -------------------------------------------------------------------------------- /pandas/tests/util/test_rewrite_warning.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | import pytest 4 | 5 | from pandas.util._exceptions import rewrite_warning 6 | 7 | import pandas._testing as tm 8 | 9 | 10 | @pytest.mark.parametrize( 11 | "target_category, target_message, hit", 12 | [ 13 | (FutureWarning, "Target message", True), 14 | (FutureWarning, "Target", True), 15 | (FutureWarning, "get mess", True), 16 | (FutureWarning, "Missed message", False), 17 | (DeprecationWarning, "Target message", False), 18 | ], 19 | ) 20 | @pytest.mark.parametrize( 21 | "new_category", 22 | [ 23 | None, 24 | DeprecationWarning, 25 | ], 26 | ) 27 | def test_rewrite_warning(target_category, target_message, hit, new_category): 28 | new_message = "Rewritten message" 29 | if hit: 30 | expected_category = new_category if new_category else target_category 31 | expected_message = new_message 32 | else: 33 | expected_category = FutureWarning 34 | expected_message = "Target message" 35 | with tm.assert_produces_warning(expected_category, match=expected_message): 36 | with rewrite_warning( 37 | target_message, target_category, new_message, new_category 38 | ): 39 | warnings.warn(message="Target message", category=FutureWarning) 40 | -------------------------------------------------------------------------------- /pandas/tests/util/test_shares_memory.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import pandas.util._test_decorators as td 4 | 5 | import pandas as pd 6 | import pandas._testing as tm 7 | 8 | 9 | def test_shares_memory_interval(): 10 | obj = pd.interval_range(1, 5) 11 | 12 | assert tm.shares_memory(obj, obj) 13 | assert tm.shares_memory(obj, obj._data) 14 | assert tm.shares_memory(obj, obj[::-1]) 15 | assert tm.shares_memory(obj, obj[:2]) 16 | 17 | assert not tm.shares_memory(obj, obj._data.copy()) 18 | 19 | 20 | @td.skip_if_no("pyarrow") 21 | def test_shares_memory_string(): 22 | # GH#55823 23 | import pyarrow as pa 24 | 25 | obj = pd.array(["a", "b"], dtype=pd.StringDtype("pyarrow", na_value=pd.NA)) 26 | assert tm.shares_memory(obj, obj) 27 | 28 | obj = pd.array(["a", "b"], dtype=pd.StringDtype("pyarrow", na_value=np.nan)) 29 | assert tm.shares_memory(obj, obj) 30 | 31 | obj = pd.array(["a", "b"], dtype=pd.ArrowDtype(pa.string())) 32 | assert tm.shares_memory(obj, obj) 33 | -------------------------------------------------------------------------------- /pandas/tests/util/test_validate_inclusive.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from pandas.util._validators import validate_inclusive 5 | 6 | import pandas as pd 7 | 8 | 9 | @pytest.mark.parametrize( 10 | "invalid_inclusive", 11 | ( 12 | "ccc", 13 | 2, 14 | object(), 15 | None, 16 | np.nan, 17 | pd.NA, 18 | pd.DataFrame(), 19 | ), 20 | ) 21 | def test_invalid_inclusive(invalid_inclusive): 22 | with pytest.raises( 23 | ValueError, 24 | match="Inclusive has to be either 'both', 'neither', 'left' or 'right'", 25 | ): 26 | validate_inclusive(invalid_inclusive) 27 | 28 | 29 | @pytest.mark.parametrize( 30 | "valid_inclusive, expected_tuple", 31 | ( 32 | ("left", (True, False)), 33 | ("right", (False, True)), 34 | ("both", (True, True)), 35 | ("neither", (False, False)), 36 | ), 37 | ) 38 | def test_valid_inclusive(valid_inclusive, expected_tuple): 39 | resultant_tuple = validate_inclusive(valid_inclusive) 40 | assert expected_tuple == resultant_tuple 41 | -------------------------------------------------------------------------------- /pandas/tests/window/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/window/__init__.py -------------------------------------------------------------------------------- /pandas/tests/window/moments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pandas-dev/pandas/c708e152c42f81b17cf6e47f7939a86e4c3fc77f/pandas/tests/window/moments/__init__.py -------------------------------------------------------------------------------- /pandas/tseries/__init__.py: -------------------------------------------------------------------------------- 1 | # ruff: noqa: TC004 2 | from typing import TYPE_CHECKING 3 | 4 | if TYPE_CHECKING: 5 | # import modules that have public classes/functions: 6 | from pandas.tseries import ( 7 | frequencies, 8 | offsets, 9 | ) 10 | 11 | # and mark only those modules as public 12 | __all__ = ["frequencies", "offsets"] 13 | -------------------------------------------------------------------------------- /pandas/tseries/api.py: -------------------------------------------------------------------------------- 1 | """ 2 | Timeseries API 3 | """ 4 | 5 | from pandas._libs.tslibs.parsing import guess_datetime_format 6 | 7 | from pandas.tseries import offsets 8 | from pandas.tseries.frequencies import infer_freq 9 | 10 | __all__ = ["guess_datetime_format", "infer_freq", "offsets"] 11 | -------------------------------------------------------------------------------- /pandas/util/__init__.py: -------------------------------------------------------------------------------- 1 | def __getattr__(key: str): 2 | # These imports need to be lazy to avoid circular import errors 3 | if key == "hash_array": 4 | from pandas.core.util.hashing import hash_array 5 | 6 | return hash_array 7 | if key == "hash_pandas_object": 8 | from pandas.core.util.hashing import hash_pandas_object 9 | 10 | return hash_pandas_object 11 | if key == "Appender": 12 | from pandas.util._decorators import Appender 13 | 14 | return Appender 15 | if key == "Substitution": 16 | from pandas.util._decorators import Substitution 17 | 18 | return Substitution 19 | 20 | if key == "cache_readonly": 21 | from pandas.util._decorators import cache_readonly 22 | 23 | return cache_readonly 24 | 25 | raise AttributeError(f"module 'pandas.util' has no attribute '{key}'") 26 | 27 | 28 | def __dir__() -> list[str]: 29 | return list(globals().keys()) + ["hash_array", "hash_pandas_object"] 30 | -------------------------------------------------------------------------------- /scripts/cibw_before_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Add 3rd party licenses, like numpy does 3 | for file in $PACKAGE_DIR/LICENSES/*; do 4 | cat $file >> $PACKAGE_DIR/LICENSE 5 | done 6 | -------------------------------------------------------------------------------- /tooling/debug/README: -------------------------------------------------------------------------------- 1 | The Docker image here helps to set up an isolated environment containing a debug version of Python and a gdb installation which the Cython debugger can work with. 2 | 3 | If you have internet access, you can pull a pre-built image via 4 | 5 | ```sh 6 | docker pull pandas/pandas-debug 7 | ``` 8 | 9 | To build the image locally, you can do 10 | 11 | ```sh 12 | docker build . -t pandas/pandas-debug -f Dockerfile.pandas-debug 13 | ``` 14 | 15 | For pandas developers, you can push a new copy of the image to dockerhub via 16 | 17 | ```sh 18 | docker push pandas/pandas-debug 19 | ``` 20 | --------------------------------------------------------------------------------