Initial commit: 首次建仓,建立目录结构

This commit is contained in:
FXY
2026-06-11 23:49:54 +08:00
commit 4038a476b5
9396 changed files with 2372905 additions and 0 deletions

View File

@ -0,0 +1,19 @@
"""public toolkit API"""
from pandas.api import (
executors,
extensions,
indexers,
interchange,
types,
typing,
)
__all__ = [
"executors",
"extensions",
"indexers",
"interchange",
"types",
"typing",
]

View File

@ -0,0 +1,7 @@
"""
Public API for function executor engines to be used with ``map`` and ``apply``.
"""
from pandas.core.apply import BaseExecutionEngine
__all__ = ["BaseExecutionEngine"]

View File

@ -0,0 +1,33 @@
"""
Public API for extending pandas objects.
"""
from pandas._libs.lib import no_default
from pandas.core.dtypes.base import (
ExtensionDtype,
register_extension_dtype,
)
from pandas.core.accessor import (
register_dataframe_accessor,
register_index_accessor,
register_series_accessor,
)
from pandas.core.algorithms import take
from pandas.core.arrays import (
ExtensionArray,
ExtensionScalarOpsMixin,
)
__all__ = [
"ExtensionArray",
"ExtensionDtype",
"ExtensionScalarOpsMixin",
"no_default",
"register_dataframe_accessor",
"register_extension_dtype",
"register_index_accessor",
"register_series_accessor",
"take",
]

View File

@ -0,0 +1,17 @@
"""
Public API for Rolling Window Indexers.
"""
from pandas.core.indexers import check_array_indexer
from pandas.core.indexers.objects import (
BaseIndexer,
FixedForwardWindowIndexer,
VariableOffsetWindowIndexer,
)
__all__ = [
"BaseIndexer",
"FixedForwardWindowIndexer",
"VariableOffsetWindowIndexer",
"check_array_indexer",
]

View File

@ -0,0 +1,8 @@
"""
Public API for DataFrame interchange protocol.
"""
from pandas.core.interchange.dataframe_protocol import DataFrame
from pandas.core.interchange.from_dataframe import from_dataframe
__all__ = ["DataFrame", "from_dataframe"]

View File

@ -0,0 +1,62 @@
import numpy as np
from pandas._typing import ArrayLike
from pandas import (
DataFrame,
Index,
)
from pandas.core.internals.api import _make_block
from pandas.core.internals.managers import BlockManager as _BlockManager
def create_dataframe_from_blocks(
blocks: list[tuple[ArrayLike, np.ndarray]], index: Index, columns: Index
) -> DataFrame:
"""
Low-level function to create a DataFrame from arrays as they are
representing the block structure of the resulting DataFrame.
Attention: this is an advanced, low-level function that should only be
used if you know that the below-mentioned assumptions are guaranteed.
If passing data that do not follow those assumptions, subsequent
subsequent operations on the resulting DataFrame might lead to strange
errors.
For almost all use cases, you should use the standard pd.DataFrame(..)
constructor instead. If you are planning to use this function, let us
know by opening an issue at https://github.com/pandas-dev/pandas/issues.
Assumptions:
- The block arrays are either a 2D numpy array or a pandas ExtensionArray
- In case of a numpy array, it is assumed to already be in the expected
shape for Blocks (2D, (cols, rows), i.e. transposed compared to the
DataFrame columns).
- All arrays are taken as is (no type inference) and expected to have the
correct size.
- The placement arrays have the correct length (equalling the number of
columns that its equivalent block array represents), and all placement
arrays together form a complete set of 0 to n_columns - 1.
Parameters
----------
blocks : list of tuples of (block_array, block_placement)
This should be a list of tuples existing of (block_array, block_placement),
where:
- block_array is a 2D numpy array or a 1D ExtensionArray, following the
requirements listed above.
- block_placement is a 1D integer numpy array
index : Index
The Index object for the `index` of the resulting DataFrame.
columns : Index
The Index object for the `columns` of the resulting DataFrame.
Returns
-------
DataFrame
"""
block_objs = [_make_block(*block) for block in blocks]
axes = [columns, index]
mgr = _BlockManager(block_objs, axes)
return DataFrame._from_mgr(mgr, mgr.axes)

View File

@ -0,0 +1,23 @@
"""
Public toolkit API.
"""
from pandas._libs.lib import infer_dtype
from pandas.core.dtypes.api import * # noqa: F403
from pandas.core.dtypes.concat import union_categoricals
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
PeriodDtype,
)
__all__ = [
"CategoricalDtype",
"DatetimeTZDtype",
"IntervalDtype",
"PeriodDtype",
"infer_dtype",
"union_categoricals",
]

View File

@ -0,0 +1,61 @@
"""
Public API classes that store intermediate results useful for type-hinting.
"""
from pandas._libs import NaTType
from pandas._libs.lib import NoDefault
from pandas._libs.missing import NAType
from pandas.core.col import Expression
from pandas.core.groupby import (
DataFrameGroupBy,
SeriesGroupBy,
)
from pandas.core.indexes.frozen import FrozenList
from pandas.core.resample import (
DatetimeIndexResamplerGroupby,
PeriodIndexResamplerGroupby,
Resampler,
TimedeltaIndexResamplerGroupby,
TimeGrouper,
)
from pandas.core.window import (
Expanding,
ExpandingGroupby,
ExponentialMovingWindow,
ExponentialMovingWindowGroupby,
Rolling,
RollingGroupby,
Window,
)
# TODO: Can't import Styler without importing jinja2
# from pandas.io.formats.style import Styler
from pandas.io.json._json import JsonReader
from pandas.io.sas.sasreader import SASReader
from pandas.io.stata import StataReader
__all__ = [
"DataFrameGroupBy",
"DatetimeIndexResamplerGroupby",
"Expanding",
"ExpandingGroupby",
"ExponentialMovingWindow",
"ExponentialMovingWindowGroupby",
"Expression",
"FrozenList",
"JsonReader",
"NAType",
"NaTType",
"NoDefault",
"PeriodIndexResamplerGroupby",
"Resampler",
"Rolling",
"RollingGroupby",
"SASReader",
"SeriesGroupBy",
"StataReader",
"TimeGrouper",
"TimedeltaIndexResamplerGroupby",
"Window",
]

View File

@ -0,0 +1,145 @@
from pandas._typing import (
AggFuncType,
AlignJoin,
AnyAll,
AnyArrayLike,
ArrayLike,
AstypeArg,
Axes,
Axis,
ColspaceArgType,
CompressionOptions,
CorrelationMethod,
CSVEngine,
DropKeep,
Dtype,
DtypeArg,
DtypeBackend,
DtypeObj,
ExcelWriterIfSheetExists,
ExcelWriterMergeCells,
FilePath,
FillnaOptions,
FloatFormatType,
FormattersType,
FromDictOrient,
HTMLFlavors,
IgnoreRaise,
IndexLabel,
InterpolateOptions,
IntervalClosedType,
IntervalLeftRight,
JoinHow,
JoinValidate,
JSONEngine,
JSONSerializable,
ListLike,
MergeHow,
MergeValidate,
NaPosition,
NsmallestNlargestKeep,
OpenFileErrors,
Ordered,
ParquetCompressionOptions,
QuantileInterpolation,
ReadBuffer,
ReadCsvBuffer,
ReadPickleBuffer,
ReindexMethod,
Scalar,
ScalarIndexer,
SequenceIndexer,
SequenceNotStr,
SliceType,
SortKind,
StorageOptions,
Suffixes,
TakeIndexer,
TimeAmbiguous,
TimedeltaConvertibleTypes,
TimeGrouperOrigin,
TimeNonexistent,
TimestampConvertibleTypes,
TimeUnit,
ToStataByteorder,
ToTimestampHow,
UpdateJoin,
UsecolsArgType,
WindowingRankType,
WriteBuffer,
WriteExcelBuffer,
XMLParsers,
)
__all__ = [
"AggFuncType",
"AlignJoin",
"AnyAll",
"AnyArrayLike",
"ArrayLike",
"AstypeArg",
"Axes",
"Axis",
"CSVEngine",
"ColspaceArgType",
"CompressionOptions",
"CorrelationMethod",
"DropKeep",
"Dtype",
"DtypeArg",
"DtypeBackend",
"DtypeObj",
"ExcelWriterIfSheetExists",
"ExcelWriterMergeCells",
"FilePath",
"FillnaOptions",
"FloatFormatType",
"FormattersType",
"FromDictOrient",
"HTMLFlavors",
"IgnoreRaise",
"IndexLabel",
"InterpolateOptions",
"IntervalClosedType",
"IntervalLeftRight",
"JSONEngine",
"JSONSerializable",
"JoinHow",
"JoinValidate",
"ListLike",
"MergeHow",
"MergeValidate",
"NaPosition",
"NsmallestNlargestKeep",
"OpenFileErrors",
"Ordered",
"ParquetCompressionOptions",
"QuantileInterpolation",
"ReadBuffer",
"ReadCsvBuffer",
"ReadPickleBuffer",
"ReindexMethod",
"Scalar",
"ScalarIndexer",
"SequenceIndexer",
"SequenceNotStr",
"SliceType",
"SortKind",
"StorageOptions",
"Suffixes",
"TakeIndexer",
"TimeAmbiguous",
"TimeGrouperOrigin",
"TimeNonexistent",
"TimeUnit",
"TimedeltaConvertibleTypes",
"TimestampConvertibleTypes",
"ToStataByteorder",
"ToTimestampHow",
"UpdateJoin",
"UsecolsArgType",
"WindowingRankType",
"WriteBuffer",
"WriteExcelBuffer",
"XMLParsers",
]