Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3.x' into string-dtype-2.3.x…
Browse files Browse the repository at this point in the history
…-downcast-string
  • Loading branch information
jorisvandenbossche committed Dec 13, 2024
2 parents 2c0c5b1 + ffe0791 commit dd96604
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- checkout
- run: .circleci/setup_env.sh
- run: |
sudo apt-get update && sudo apt-get install -y libegl1 libopengl0
PATH=$HOME/miniconda3/envs/pandas-dev/bin:$HOME/miniconda3/condabin:$PATH \
LD_PRELOAD=$HOME/miniconda3/envs/pandas-dev/lib/libgomp.so.1:$LD_PRELOAD \
ci/run_tests.sh
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,10 @@ def construct_1d_object_array_from_listlike(values: Collection) -> np.ndarray:
"""
# numpy will try to interpret nested lists as further dimensions in np.array(),
# hence explicitly making a 1D array using np.fromiter
return np.fromiter(values, dtype="object", count=len(values))
result = np.empty(len(values), dtype="object")
for i, obj in enumerate(values):
result[i] = obj
return result


def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ def test_from_arrow_respecting_given_dtype():

def test_from_arrow_respecting_given_dtype_unsafe():
array = pa.array([1.5, 2.5], type=pa.float64())
with pytest.raises(pa.ArrowInvalid, match="Float value 1.5 was truncated"):
with tm.external_error_raised(pa.ArrowInvalid):
array.to_pandas(types_mapper={pa.float64(): ArrowDtype(pa.int64())}.get)


Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/io/test_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from pandas._config import using_string_dtype

from pandas.compat import HAS_PYARROW

from pandas import (
DataFrame,
date_range,
Expand Down Expand Up @@ -168,7 +170,9 @@ def test_excel_options(fsspectest):
assert fsspectest.test[0] == "read"


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) fastparquet")
@pytest.mark.xfail(
using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string) fastparquet"
)
def test_to_parquet_new_file(cleared_fs, df1):
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
pytest.importorskip("fastparquet")
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/io/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat.pyarrow import pa_version_under17p0

from pandas import (
Expand Down Expand Up @@ -196,7 +194,6 @@ def test_to_csv_compression_encoding_gcs(
tm.assert_frame_equal(df, read_df)


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) fastparquet")
def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
pytest.importorskip("fastparquet")
Expand Down

0 comments on commit dd96604

Please sign in to comment.