Search is not available for this dataset
repo_id stringlengths 12 110 | file_path stringlengths 24 164 | content stringlengths 3 89.3M | __index_level_0__ int64 0 0 |
|---|---|---|---|
public_repos/pandas | public_repos/pandas/scripts/validate_docstrings.py | #!/usr/bin/env python3
"""
Analyze docstrings to detect errors.
If no argument is provided, it does a quick check of docstrings and returns
a csv with all API functions and results of basic checks.
If a function or method is provided in the form "pandas.function",
"pandas.module.class.method", etc. a list of all erro... | 0 |
public_repos/pandas | public_repos/pandas/scripts/validate_rst_title_capitalization.py | """
Validate that the titles in the rst files follow the proper capitalization convention.
Print the titles that do not follow the convention.
Usage::
As pre-commit hook (recommended):
pre-commit run title-capitalization --all-files
From the command-line:
python scripts/validate_rst_title_capitalization.py ... | 0 |
public_repos/pandas | public_repos/pandas/scripts/run_stubtest.py | import os
from pathlib import Path
import sys
import tempfile
import warnings
from mypy import stubtest
import pandas as pd
pd_version = getattr(pd, "__version__", "")
# fail early if pandas is not installed
if not pd_version:
# fail on the CI, soft fail during local development
warnings.warn("You need to i... | 0 |
public_repos/pandas | public_repos/pandas/scripts/check_test_naming.py | """
Check that test names start with `test`, and that test classes start with `Test`.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run check-test-naming --all-files
NOTE: if this finds a false positive, you can add the comment `# not a test` to the
class or function d... | 0 |
public_repos/pandas | public_repos/pandas/scripts/check_for_inconsistent_pandas_namespace.py | """
Check that test suite file doesn't use the pandas namespace inconsistently.
We check for cases of ``Series`` and ``pd.Series`` appearing in the same file
(likewise for other pandas objects).
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run inconsistent-namespace-u... | 0 |
public_repos/pandas | public_repos/pandas/scripts/download_wheels.sh | #!/bin/sh
#
# Download all wheels for a pandas version.
#
# This script is mostly useful during the release process, when wheels
# generated by the MacPython repo need to be downloaded locally to then
# be uploaded to the PyPI.
#
# There is no API to access the wheel files, so the script downloads the
# website, extrac... | 0 |
public_repos/pandas | public_repos/pandas/scripts/no_bool_in_generic.py | """
Check that pandas/core/generic.py doesn't use bool as a type annotation.
There is already the method `bool`, so the alias `bool_t` should be used instead.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run no-bool-in-core-generic --all-files
The function `visit` is... | 0 |
public_repos/pandas | public_repos/pandas/scripts/use_io_common_urlopen.py | """
Check that pandas/core imports pandas.array as pd_array.
This makes it easier to grep for usage of pandas array.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run use-io-common-urlopen --all-files
"""
from __future__ import annotations
import argparse
import ast... | 0 |
public_repos/pandas | public_repos/pandas/scripts/validate_min_versions_in_sync.py | #!/usr/bin/env python3
"""
Check pandas required and optional dependencies are synced across:
ci/deps/actions-.*-minimum_versions.yaml
pandas/compat/_optional.py
setup.cfg
TODO: doc/source/getting_started/install.rst
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run v... | 0 |
public_repos/pandas | public_repos/pandas/scripts/use_pd_array_in_core.py | """
Check that pandas/core imports pandas.array as pd_array.
This makes it easier to grep for usage of pandas array.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run use-pd_array-in-core --all-files
"""
from __future__ import annotations
import argparse
import ast
... | 0 |
public_repos/pandas | public_repos/pandas/scripts/pandas_errors_documented.py | """
Check that doc/source/reference/testing.rst documents
all exceptions and warnings in pandas/errors/__init__.py.
This is meant to be run as a pre-commit hook - to run it manually, you can do:
pre-commit run pandas-errors-documented --all-files
"""
from __future__ import annotations
import argparse
import ast
... | 0 |
public_repos/pandas | public_repos/pandas/scripts/validate_exception_location.py | """
Validate that the exceptions and warnings are in appropriate places.
Checks for classes that inherit a python exception and warning and
flags them, unless they are exempted from checking. Exempt meaning
the exception/warning is defined in testing.rst. Testing.rst contains
a list of pandas defined exceptions and wa... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_check_test_naming.py | import pytest
from scripts.check_test_naming import main
@pytest.mark.parametrize(
"src, expected_out, expected_ret",
[
(
"def foo(): pass\n",
"t.py:1:0 found test function which does not start with 'test'\n",
1,
),
(
"class Foo:\n de... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_use_io_common_urlopen.py | import pytest
from scripts.use_io_common_urlopen import use_io_common_urlopen
PATH = "t.py"
def test_inconsistent_usage(capsys):
content = "from urllib.request import urlopen"
result_msg = (
"t.py:1:0: Don't use urllib.request.urlopen, "
"use pandas.io.common.urlopen instead\n"
)
wit... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_sort_whatsnew_note.py | from scripts.sort_whatsnew_note import sort_whatsnew_note
def test_sort_whatsnew_note():
content = (
".. _whatsnew_200:\n"
"\n"
"What's new in 2.0.0 (March XX, 2023)\n"
"------------------------------------\n"
"\n"
"Timedelta\n"
"^^^^^^^^^\n"
"- Bug ... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_validate_unwanted_patterns.py | import io
import pytest
from scripts import validate_unwanted_patterns
class TestBarePytestRaises:
@pytest.mark.parametrize(
"data",
[
(
"""
with pytest.raises(ValueError, match="foo"):
pass
"""
),
(
"""
# wi... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/conftest.py | # pyproject.toml defines addopts: --strict-data-files
# strict-data-files is defined & used in pandas/conftest.py
def pytest_addoption(parser):
parser.addoption(
"--strict-data-files",
action="store_true",
help="Unused",
)
| 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_no_bool_in_generic.py | from scripts.no_bool_in_generic import check_for_bool_in_generic
BAD_FILE = "def foo(a: bool) -> bool:\n return bool(0)\n"
GOOD_FILE = "def foo(a: bool_t) -> bool_t:\n return bool(0)\n"
def test_bad_file_with_replace():
content = BAD_FILE
mutated, result = check_for_bool_in_generic(content)
expecte... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_validate_exception_location.py | import pytest
from scripts.validate_exception_location import (
ERROR_MESSAGE,
validate_exception_and_warning_placement,
)
PATH = "t.py"
# ERRORS_IN_TESTING_RST is the set returned when parsing testing.rst for all the
# exceptions and warnings.
CUSTOM_EXCEPTION_NOT_IN_TESTING_RST = "MyException"
CUSTOM_EXCEP... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_validate_docstrings.py | import io
import textwrap
import pytest
from scripts import validate_docstrings
class BadDocstrings:
"""Everything here has a bad docstring"""
def private_classes(self):
"""
This mentions NDFrame, which is not correct.
"""
def prefix_pandas(self):
"""
Have `pand... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_validate_min_versions_in_sync.py | import pathlib
import sys
import pytest
import yaml
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
from scripts.validate_min_versions_in_sync import (
get_toml_map_from,
get_yaml_map_from,
pin_min_versions_to_yaml_file,
)
@pytest.mark.parametrize(
"src_toml, sr... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_inconsistent_namespace_check.py | import pytest
from scripts.check_for_inconsistent_pandas_namespace import (
check_for_inconsistent_pandas_namespace,
)
BAD_FILE_0 = (
"from pandas import Categorical\n"
"cat_0 = Categorical()\n"
"cat_1 = pd.Categorical()"
)
BAD_FILE_1 = (
"from pandas import Categorical\n"
"cat_0 = pd.Categori... | 0 |
public_repos/pandas/scripts | public_repos/pandas/scripts/tests/test_use_pd_array_in_core.py | import pytest
from scripts.use_pd_array_in_core import use_pd_array
BAD_FILE_0 = "import pandas as pd\npd.array"
BAD_FILE_1 = "\nfrom pandas import array"
GOOD_FILE_0 = "from pandas import array as pd_array"
GOOD_FILE_1 = "from pandas.core.construction import array as pd_array"
PATH = "t.py"
@pytest.mark.parametriz... | 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_expected_same_version.yaml | # Test: same version
dependencies:
- jinja2>=3.0.0
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_unmodified_random.yaml | # Test: random
name: pandas-dev
channels:
- conda-forge
dependencies:
- python=3.8
# build dependencies
- versioneer[toml]
- cython>=0.29.32
# test dependencies
- pytest>=7.3.2
- pytest-cov
- pytest-xdist>=2.2.0
- psutil
- boto3
# required dependencies
- python-dateutil
- numpy
- pytz
... | 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_expected_range.yaml | # Test: range
dependencies:
- jinja2<8, >=3.0.0
- scipy<9, >=1.7.1
- SQLAlchemy<2.0, >=1.4.16
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_expected_random.yaml | # Test: random
name: pandas-dev
channels:
- conda-forge
dependencies:
- python=3.8
# build dependencies
- versioneer[toml]
- cython>=0.29.32
# test dependencies
- pytest>=7.3.2
- pytest-cov
- pytest-xdist>=2.2.0
- psutil
- boto3
# required dependencies
- python-dateutil
- numpy
- pytz
... | 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_unmodified_no_version.yaml | # Test: empty version
dependencies:
- jinja2
- scipy
- SQLAlchemy
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_unmodified_same_version.yaml | # Test: same version
dependencies:
- jinja2>=3.0.0
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_expected_duplicate_package.yaml | # Test: duplicate package
dependencies:
- jinja2>=3.0.0
- jinja2>=3.0.0
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_expected_no_version.yaml | # Test: empty version
dependencies:
- jinja2>=3.0.0
- scipy>=1.7.1
- SQLAlchemy>=1.4.16
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_unmodified_range.yaml | # Test: range
dependencies:
- jinja2<8
- scipy<9
- SQLAlchemy<2.0
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_unmodified_duplicate_package.yaml | # Test: duplicate package
dependencies:
- jinja2>=3.0.0
- jinja2>=3.0.0
| 0 |
public_repos/pandas/scripts/tests | public_repos/pandas/scripts/tests/data/deps_minimum.toml | [build-system]
# Minimum requirements for the build system to execute.
# See https://github.com/scipy/scipy/pull/12940 for the AIX issue.
requires = [
"setuptools>=61.0.0",
"wheel",
"Cython>=0.29.32,<3", # Note: sync with setup.py, environment.yml and asv.conf.json
"oldest-supported-numpy>=2022.8.16",
... | 0 |
public_repos/pandas | public_repos/pandas/asv_bench/asv.conf.json | {
// The version of the config file format. Do not change, unless
// you know what you are doing.
"version": 1,
// The name of the project being benchmarked
"project": "pandas",
// The project's homepage
"project_url": "https://pandas.pydata.org/",
// The URL of the source code repos... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/package.py | """
Benchmarks for pandas at the package-level.
"""
import subprocess
import sys
class TimeImport:
def time_import(self):
# on py37+ we the "-X importtime" usage gives us a more precise
# measurement of the import time we actually care about,
# without the subprocess or interpreter overh... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/reindex.py | import numpy as np
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
date_range,
period_range,
)
from .pandas_vb_common import tm
class Reindex:
def setup(self):
rng = date_range(start="1/1/1970", periods=10000, freq="1min")
self.df = DataFrame(np.random.rand(100... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/pandas_vb_common.py | from importlib import import_module
import os
import numpy as np
import pandas as pd
# Compatibility import for lib
for imp in ["pandas._libs.lib", "pandas.lib"]:
try:
lib = import_module(imp)
break
except (ImportError, TypeError, ValueError):
pass
# Compatibility import for the test... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/strftime.py | import numpy as np
import pandas as pd
from pandas import offsets
class DatetimeStrftime:
timeout = 1500
params = [1000, 10000]
param_names = ["nobs"]
def setup(self, nobs):
d = "2018-11-29"
dt = "2018-11-26 11:18:27.0"
self.data = pd.DataFrame(
{
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/libs.py | """
Benchmarks for code in pandas/_libs, excluding pandas/_libs/tslibs,
which has its own directory.
If a PR does not edit anything in _libs/, then it is unlikely that the
benchmarks will be affected.
"""
import numpy as np
from pandas._libs.lib import (
infer_dtype,
is_list_like,
is_scalar,
)
from panda... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/rolling.py | import warnings
import numpy as np
import pandas as pd
class Methods:
params = (
["DataFrame", "Series"],
[("rolling", {"window": 10}), ("rolling", {"window": 1000}), ("expanding", {})],
["int", "float"],
["median", "mean", "max", "min", "std", "count", "skew", "kurt", "sum", "se... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/index_object.py | import gc
import numpy as np
from pandas import (
DatetimeIndex,
Index,
IntervalIndex,
MultiIndex,
RangeIndex,
Series,
date_range,
)
from .pandas_vb_common import tm
class SetOperations:
params = (
["monotonic", "non_monotonic"],
["datetime", "date_string", "int", "s... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/array.py | import numpy as np
import pandas as pd
class BooleanArray:
def setup(self):
self.values_bool = np.array([True, False, True, False])
self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
self.values_integer = np.array([1, 0, 1, 0])
self.values_integer_like = [1, 0, 1, 0]
self.... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/gil.py | from functools import wraps
import threading
import numpy as np
from pandas import (
DataFrame,
Series,
date_range,
factorize,
read_csv,
)
from pandas.core.algorithms import take_nd
from .pandas_vb_common import tm
try:
from pandas import (
rolling_kurt,
rolling_max,
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/boolean.py | import numpy as np
import pandas as pd
class TimeLogicalOps:
def setup(self):
N = 10_000
left, right, lmask, rmask = np.random.randint(0, 2, size=(4, N)).astype("bool")
self.left = pd.arrays.BooleanArray(left, lmask)
self.right = pd.arrays.BooleanArray(right, rmask)
def time_... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/period.py | """
Period benchmarks with non-tslibs dependencies. See
benchmarks.tslibs.period for benchmarks that rely only on tslibs.
"""
from pandas import (
DataFrame,
Period,
PeriodIndex,
Series,
date_range,
period_range,
)
from pandas.tseries.frequencies import to_offset
class PeriodIndexConstructor... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/index_cached_properties.py | import pandas as pd
class IndexCache:
number = 1
repeat = (3, 100, 20)
params = [
[
"CategoricalIndex",
"DatetimeIndex",
"Float64Index",
"IntervalIndex",
"Int64Index",
"MultiIndex",
"PeriodIndex",
"Ran... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/frame_methods.py | import string
import warnings
import numpy as np
from pandas import (
DataFrame,
MultiIndex,
NaT,
Series,
date_range,
isnull,
period_range,
timedelta_range,
)
from .pandas_vb_common import tm
class AsType:
params = [
[
# from_dtype == to_dtype
("F... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/indexing.py | """
These benchmarks are for Series and DataFrame indexing methods. For the
lower-level methods directly on Index and subclasses, see index_object.py,
indexing_engine.py, and index_cached.py
"""
from datetime import datetime
import warnings
import numpy as np
from pandas import (
NA,
CategoricalIndex,
Da... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/finalize.py | import pandas as pd
class Finalize:
param_names = ["series", "frame"]
params = [pd.Series, pd.DataFrame]
def setup(self, param):
N = 1000
obj = param(dtype=float)
for i in range(N):
obj.attrs[i] = i
self.obj = obj
def time_finalize_micro(self, param):
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/strings.py | import warnings
import numpy as np
from pandas import (
NA,
Categorical,
DataFrame,
Series,
)
from pandas.arrays import StringArray
from .pandas_vb_common import tm
class Dtypes:
params = ["str", "string[python]", "string[pyarrow]"]
param_names = ["dtype"]
def setup(self, dtype):
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/algorithms.py | from importlib import import_module
import numpy as np
import pandas as pd
from .pandas_vb_common import tm
for imp in ["pandas.util", "pandas.tools.hashing"]:
try:
hashing = import_module(imp)
break
except (ImportError, TypeError, ValueError):
pass
class Factorize:
params = [
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/ctors.py | import numpy as np
from pandas import (
DatetimeIndex,
Index,
MultiIndex,
Series,
Timestamp,
date_range,
)
from .pandas_vb_common import tm
def no_change(arr):
return arr
def list_of_str(arr):
return list(arr.astype(str))
def gen_of_str(arr):
return (x for x in arr.astype(str... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/eval.py | import numpy as np
import pandas as pd
try:
import pandas.core.computation.expressions as expr
except ImportError:
import pandas.computation.expressions as expr
class Eval:
params = [["numexpr", "python"], [1, "all"]]
param_names = ["engine", "threads"]
def setup(self, engine, threads):
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/attrs_caching.py | import numpy as np
import pandas as pd
from pandas import DataFrame
try:
from pandas.core.construction import extract_array
except ImportError:
extract_array = None
class DataFrameAttributes:
def setup(self):
self.df = DataFrame(np.random.randn(10, 6))
self.cur_index = self.df.index
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/reshape.py | from itertools import product
import string
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
date_range,
melt,
wide_to_long,
)
from pandas.api.types import CategoricalDtype
class Melt:
params = ["float64", "Float64"]
param_names = ["dtype"]
def setu... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/groupby.py | from functools import partial
from itertools import product
from string import ascii_letters
import numpy as np
from pandas import (
NA,
Categorical,
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
date_range,
period_range,
to_timedelta,
)
from .pandas_vb_common import tm
me... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/timedelta.py | """
Timedelta benchmarks with non-tslibs dependencies. See
benchmarks.tslibs.timedelta for benchmarks that rely only on tslibs.
"""
from pandas import (
DataFrame,
Series,
timedelta_range,
)
class DatetimeAccessor:
def setup_cache(self):
N = 100000
series = Series(timedelta_range("1 ... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/indexing_engines.py | """
Benchmarks in this file depend mostly on code in _libs/
We have to created masked arrays to test the masked engine though. The
array is unpacked on the Cython level.
If a PR does not edit anything in _libs, it is very unlikely that benchmarks
in this file will be affected.
"""
import numpy as np
from pandas._li... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/series_methods.py | from datetime import datetime
import numpy as np
from pandas import (
NA,
Index,
NaT,
Series,
date_range,
)
from .pandas_vb_common import tm
class SeriesConstructor:
def setup(self):
self.idx = date_range(
start=datetime(2015, 10, 26), end=datetime(2016, 1, 1), freq="50s... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/arithmetic.py | import operator
import warnings
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
Series,
Timestamp,
date_range,
to_timedelta,
)
import pandas._testing as tm
from pandas.core.algorithms import checked_add_with_arr
from .pandas_vb_common import numeric_dtypes
try:
import ... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/timeseries.py | from datetime import timedelta
import dateutil
import numpy as np
from pandas import (
DataFrame,
Series,
date_range,
period_range,
timedelta_range,
)
from pandas.tseries.frequencies import infer_freq
try:
from pandas.plotting._matplotlib.converter import DatetimeConverter
except ImportError... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/hash_functions.py | import numpy as np
import pandas as pd
class UniqueForLargePyObjectInts:
def setup(self):
lst = [x << 32 for x in range(5000)]
self.arr = np.array(lst, dtype=np.object_)
def time_unique(self):
pd.unique(self.arr)
class Float64GroupIndex:
# GH28303
def setup(self):
s... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/replace.py | import numpy as np
import pandas as pd
class FillNa:
params = [True, False]
param_names = ["inplace"]
def setup(self, inplace):
N = 10**6
rng = pd.date_range("1/1/2000", periods=N, freq="min")
data = np.random.randn(N)
data[::2] = np.nan
self.ts = pd.Series(data, ... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/multiindex_object.py | import string
import numpy as np
from pandas import (
NA,
DataFrame,
MultiIndex,
RangeIndex,
Series,
array,
date_range,
)
from .pandas_vb_common import tm
class GetLoc:
def setup(self):
self.mi_large = MultiIndex.from_product(
[np.arange(1000), np.arange(20), lis... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/categoricals.py | import string
import sys
import warnings
import numpy as np
import pandas as pd
from .pandas_vb_common import tm
try:
from pandas.api.types import union_categoricals
except ImportError:
try:
from pandas.types.concat import union_categoricals
except ImportError:
pass
class Constructor:
... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/plotting.py | import contextlib
import importlib.machinery
import importlib.util
import os
import pathlib
import sys
import tempfile
from unittest import mock
import matplotlib
import numpy as np
from pandas import (
DataFrame,
DatetimeIndex,
Series,
date_range,
)
try:
from pandas.plotting import andrews_curve... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/join_merge.py | import string
import numpy as np
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
array,
concat,
date_range,
merge,
merge_asof,
)
from .pandas_vb_common import tm
try:
from pandas import merge_ordered
except ImportError:
from pandas import ordered_merge as merge... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/inference.py | """
The functions benchmarked in this file depend _almost_ exclusively on
_libs, but not in a way that is easy to formalize.
If a PR does not change anything in pandas/_libs/ or pandas/core/tools/, then
it is likely that these benchmarks will be unaffected.
"""
import numpy as np
from pandas import (
NaT,
Se... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/stat_ops.py | import numpy as np
import pandas as pd
ops = ["mean", "sum", "median", "std", "skew", "kurt", "prod", "sem", "var"]
class FrameOps:
params = [ops, ["float", "int", "Int64"], [0, 1, None]]
param_names = ["op", "dtype", "axis"]
def setup(self, op, dtype, axis):
values = np.random.randn(100000, 4)... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/sparse.py | import numpy as np
import scipy.sparse
import pandas as pd
from pandas import (
MultiIndex,
Series,
date_range,
)
from pandas.arrays import SparseArray
def make_array(size, dense_proportion, fill_value, dtype):
dense_size = int(size * dense_proportion)
arr = np.full(size, fill_value, dtype)
i... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/__init__.py | """Pandas benchmarks."""
| 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/frame_ctor.py | import numpy as np
import pandas as pd
from pandas import (
NA,
Categorical,
DataFrame,
Float64Dtype,
MultiIndex,
Series,
Timestamp,
date_range,
)
from .pandas_vb_common import tm
try:
from pandas.tseries.offsets import (
Hour,
Nano,
)
except ImportError:
#... | 0 |
public_repos/pandas/asv_bench | public_repos/pandas/asv_bench/benchmarks/dtypes.py | import string
import numpy as np
import pandas as pd
from pandas import DataFrame
import pandas._testing as tm
from pandas.api.types import (
is_extension_array_dtype,
pandas_dtype,
)
from .pandas_vb_common import (
datetime_dtypes,
extension_dtypes,
numeric_dtypes,
string_dtypes,
)
_numpy_d... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/algos/isin.py | import numpy as np
from pandas import (
Categorical,
Index,
NaT,
Series,
date_range,
)
from ..pandas_vb_common import tm
class IsIn:
params = [
"int64",
"uint64",
"object",
"Int64",
"boolean",
"bool",
"datetime64[ns]",
"category... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/algos/__init__.py | """
algos/ directory is intended for individual functions from core.algorithms
In many cases these algorithms are reachable in multiple ways:
algos.foo(x, y)
Series(x).foo(y)
Index(x).foo(y)
pd.array(x).foo(y)
In most cases we profile the Series variant directly, trusting the performance
of the others to ... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/timestamp.py | from datetime import datetime
import numpy as np
import pytz
from pandas import Timestamp
from .tslib import _tzs
class TimestampConstruction:
def setup(self):
self.npdatetime64 = np.datetime64("2020-01-01 00:00:00")
self.dttime_unaware = datetime(2020, 1, 1, 0, 0, 0)
self.dttime_aware ... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/tz_convert.py | import numpy as np
from pytz import UTC
from pandas._libs.tslibs.tzconversion import tz_localize_to_utc
from .tslib import (
_sizes,
_tzs,
tzlocal_obj,
)
try:
old_sig = False
from pandas._libs.tslibs import tz_convert_from_utc
except ImportError:
try:
old_sig = False
from pand... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/period.py | """
Period benchmarks that rely only on tslibs. See benchmarks.period for
Period benchmarks that rely on other parts of pandas.
"""
import numpy as np
from pandas._libs.tslibs.period import (
Period,
periodarr_to_dt64arr,
)
from pandas.tseries.frequencies import to_offset
from .tslib import (
_sizes,
... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/fields.py | import numpy as np
from pandas._libs.tslibs.fields import (
get_date_field,
get_start_end_field,
get_timedelta_field,
)
from .tslib import _sizes
class TimeGetTimedeltaField:
params = [
_sizes,
["seconds", "microseconds", "nanoseconds"],
]
param_names = ["size", "field"]
... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/timedelta.py | """
Timedelta benchmarks that rely only on tslibs. See benchmarks.timedeltas for
Timedelta benchmarks that rely on other parts of pandas.
"""
import datetime
import numpy as np
from pandas import Timedelta
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
sel... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/normalize.py | try:
from pandas._libs.tslibs import (
is_date_array_normalized,
normalize_i8_timestamps,
)
except ImportError:
from pandas._libs.tslibs.conversion import (
normalize_i8_timestamps,
is_date_array_normalized,
)
import pandas as pd
from .tslib import (
_sizes,
_tz... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/offsets.py | """
offsets benchmarks that rely only on tslibs. See benchmarks.offset for
offsets benchmarks that rely on other parts of pandas.
"""
from datetime import datetime
import numpy as np
from pandas import offsets
try:
import pandas.tseries.holiday
except ImportError:
pass
hcal = pandas.tseries.holiday.USFeder... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/tslib.py | """
ipython analogue:
tr = TimeIntsToPydatetime()
mi = pd.MultiIndex.from_product(
tr.params[:-1] + ([str(x) for x in tr.params[-1]],)
)
df = pd.DataFrame(np.nan, index=mi, columns=["mean", "stdev"])
for box in tr.params[0]:
for size in tr.params[1]:
for tz in tr.params[2]:
tr.setup(box, si... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/resolution.py | """
ipython analogue:
tr = TimeResolution()
mi = pd.MultiIndex.from_product(tr.params[:-1] + ([str(x) for x in tr.params[-1]],))
df = pd.DataFrame(np.nan, index=mi, columns=["mean", "stdev"])
for unit in tr.params[0]:
for size in tr.params[1]:
for tz in tr.params[2]:
tr.setup(unit, size, tz)
... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/tslibs/__init__.py | """
Benchmarks in this directory should depend only on tslibs, tseries.offsets,
and to_offset.
i.e. any code changes that do not touch those files should not need to
run these benchmarks.
"""
| 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/hdf.py | import numpy as np
from pandas import (
DataFrame,
HDFStore,
date_range,
read_hdf,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class HDFStoreDataFrame(BaseIO):
def setup(self):
N = 25000
index = tm.makeStringIndex(N)
self.df = DataFrame(
{"float1"... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/sas.py | from pathlib import Path
from pandas import read_sas
ROOT = Path(__file__).parents[3] / "pandas" / "tests" / "io" / "sas" / "data"
class SAS:
def time_read_sas7bdat(self):
read_sas(ROOT / "test1.sas7bdat")
def time_read_xpt(self):
read_sas(ROOT / "paxraw_d_short.xpt")
def time_read_sas... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/pickle.py | import numpy as np
from pandas import (
DataFrame,
date_range,
read_pickle,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class Pickle(BaseIO):
def setup(self):
self.fname = "__test__.pkl"
N = 100000
C = 5
self.df = DataFrame(
np.random.randn(N,... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/csv.py | from io import (
BytesIO,
StringIO,
)
import random
import string
import numpy as np
from pandas import (
Categorical,
DataFrame,
concat,
date_range,
period_range,
read_csv,
to_datetime,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class ToCSV(BaseIO):
fname = "_... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/parsers.py | import numpy as np
try:
from pandas._libs.tslibs.parsing import (
_does_string_look_like_datetime,
concat_date_cols,
)
except ImportError:
# Avoid whole benchmark suite import failure on asv (currently 0.4)
pass
class DoesStringLookLikeDatetime:
params = (["2Q2005", "0.0", "10000"... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/style.py | import numpy as np
from pandas import (
DataFrame,
IndexSlice,
)
class Render:
params = [[12, 24, 36], [12, 120]]
param_names = ["cols", "rows"]
def setup(self, cols, rows):
self.df = DataFrame(
np.random.randn(rows, cols),
columns=[f"float_{i+1}" for i in range(c... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/excel.py | from io import BytesIO
import numpy as np
from odf.opendocument import OpenDocumentSpreadsheet
from odf.table import (
Table,
TableCell,
TableRow,
)
from odf.text import P
from pandas import (
DataFrame,
ExcelWriter,
date_range,
read_excel,
)
from ..pandas_vb_common import tm
def _gener... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/stata.py | import numpy as np
from pandas import (
DataFrame,
date_range,
read_stata,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class Stata(BaseIO):
params = ["tc", "td", "tm", "tw", "th", "tq", "ty"]
param_names = ["convert_dates"]
def setup(self, convert_dates):
self.fname = "... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/sql.py | import sqlite3
import numpy as np
from sqlalchemy import create_engine
from pandas import (
DataFrame,
date_range,
read_sql_query,
read_sql_table,
)
from ..pandas_vb_common import tm
class SQL:
params = ["sqlalchemy", "sqlite"]
param_names = ["connection"]
def setup(self, connection):
... | 0 |
public_repos/pandas/asv_bench/benchmarks | public_repos/pandas/asv_bench/benchmarks/io/json.py | import sys
import numpy as np
from pandas import (
DataFrame,
concat,
date_range,
json_normalize,
read_json,
timedelta_range,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
class ReadJSON(BaseIO):
fname = "__test__.json"
params = (["split", "index", "records"], ["int", "da... | 0 |
public_repos/pandas | public_repos/pandas/web/pandas_web.py | #!/usr/bin/env python3
"""
Simple static site generator for the pandas web.
pandas_web.py takes a directory as parameter, and copies all the files into the
target directory after converting markdown files into html and rendering both
markdown and html files with a context. The context is obtained by parsing
the file `... | 0 |
public_repos/pandas | public_repos/pandas/web/README.md | Directory containing the pandas website (hosted at https://pandas.pydata.org).
The website sources are in `web/pandas/`, which also include a `config.yml` file
containing the settings to build the website. The website is generated with the
command `./pandas_web.py pandas`. See `./pandas_web.py --help` and the header o... | 0 |
public_repos/pandas/web | public_repos/pandas/web/pandas/config.yml | main:
templates_path: _templates
base_template: "layout.html"
production_url: "https://pandas.pydata.org/"
ignore:
- _templates/layout.html
- config.yml
github_repo_url: pandas-dev/pandas
context_preprocessors:
- pandas_web.Preprocessors.current_year
- pandas_web.Preprocessors.navbar_add_info
- pa... | 0 |
public_repos/pandas/web | public_repos/pandas/web/pandas/contribute.md | # Contribute to pandas
_pandas_ is and will always be **free**. To make the development sustainable, we need _pandas_ users, corporate
and individual, to support the development by providing their time and money.
You can find more information about current developers in the [team page]({{ base_url }}about/team.html),... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.