Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pandas/tests/resample/test_resampler_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Timestamp,
)
import pandas._testing as tm
from pandas.core.api import Int64Index
from pandas.core.indexes.datetimes import date_range

test_frame = DataFrame(
Expand Down Expand Up @@ -333,7 +332,7 @@ def test_consistency_with_window():

# consistent return values with window
df = test_frame
expected = Int64Index([1, 2, 3], name="A")
expected = Index([1, 2, 3], name="A")
result = df.groupby("A").resample("2s").mean()
assert result.index.nlevels == 2
tm.assert_index_equal(result.index.levels[0], expected)
Expand Down
31 changes: 15 additions & 16 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CategoricalIndex,
DataFrame,
DatetimeIndex,
Index,
IntervalIndex,
MultiIndex,
PeriodIndex,
Expand All @@ -29,11 +30,6 @@
)
import pandas._testing as tm
from pandas.api.types import CategoricalDtype as CDT
from pandas.core.api import (
Float64Index,
Int64Index,
UInt64Index,
)
from pandas.core.reshape.concat import concat
from pandas.core.reshape.merge import (
MergeError,
Expand Down Expand Up @@ -1324,8 +1320,13 @@ def test_merge_two_empty_df_no_division_error(self):
["2001-01-01", "2002-02-02", "2003-03-03", pd.NaT, pd.NaT, pd.NaT]
),
),
(Float64Index([1, 2, 3]), Float64Index([1, 2, 3, None, None, None])),
(Int64Index([1, 2, 3]), Float64Index([1, 2, 3, None, None, None])),
*[
(
Index([1, 2, 3], dtype=dtyp),
Index([1, 2, 3, None, None, None], dtype=np.float64),
)
for dtyp in tm.ALL_REAL_NUMPY_DTYPES
],
(
IntervalIndex.from_tuples([(1, 2), (2, 3), (3, 4)]),
IntervalIndex.from_tuples(
Expand Down Expand Up @@ -2142,15 +2143,13 @@ def test_merge_on_indexes(self, left_df, right_df, how, sort, expected):

@pytest.mark.parametrize(
"index",
[
[Index([1, 2], dtype=dtyp, name="index_col") for dtyp in tm.ALL_REAL_NUMPY_DTYPES]
+ [
CategoricalIndex(["A", "B"], categories=["A", "B"], name="index_col"),
Float64Index([1.0, 2.0], name="index_col"),
Int64Index([1, 2], name="index_col"),
UInt64Index([1, 2], name="index_col"),
RangeIndex(start=0, stop=2, name="index_col"),
DatetimeIndex(["2018-01-01", "2018-01-02"], name="index_col"),
],
ids=lambda x: type(x).__name__,
ids=lambda x: f"{type(x).__name__}[{x.dtype}]",
)
def test_merge_index_types(index):
# gh-20777
Expand Down Expand Up @@ -2652,11 +2651,11 @@ def test_merge_duplicate_columns_with_suffix_causing_another_duplicate_raises():

def test_merge_string_float_column_result():
# GH 13353
df1 = DataFrame([[1, 2], [3, 4]], columns=pd.Index(["a", 114.0]))
df1 = DataFrame([[1, 2], [3, 4]], columns=Index(["a", 114.0]))
df2 = DataFrame([[9, 10], [11, 12]], columns=["x", "y"])
result = merge(df2, df1, how="inner", left_index=True, right_index=True)
expected = DataFrame(
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=pd.Index(["x", "y", "a", 114.0])
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=Index(["x", "y", "a", 114.0])
)
tm.assert_frame_equal(result, expected)

Expand Down Expand Up @@ -2712,8 +2711,8 @@ def test_merge_outer_with_NaN(dtype):

def test_merge_different_index_names():
# GH#45094
left = DataFrame({"a": [1]}, index=pd.Index([1], name="c"))
right = DataFrame({"a": [1]}, index=pd.Index([1], name="d"))
left = DataFrame({"a": [1]}, index=Index([1], name="c"))
right = DataFrame({"a": [1]}, index=Index([1], name="d"))
result = merge(left, right, left_on="c", right_on="d")
expected = DataFrame({"a_x": [1], "a_y": 1})
tm.assert_frame_equal(result, expected)
Expand Down