8000 BUG: item_cache invalidation by jbrockmendel · Pull Request #38351 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: item_cache invalidation #38351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert broken
  • Loading branch information
jbrockmendel committed Dec 8, 2020
commit 8029aa18287526f3f8061504c7c706a1700b877f
10 changes: 1 addition & 9 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from pandas._libs import internals as libinternals, lib
from pandas._typing import ArrayLike, DtypeObj, Label, Shape
from pandas.errors import PerformanceWarning
from pandas.util._validators import validate_bool_kwarg

from pandas.core.dtypes.cast import (
Expand Down Expand Up @@ -1223,14 +1222,7 @@ def insert(self, loc: int, item: Label, value, allow_duplicates: bool = False):
self._known_consolidated = False

if len(self.blocks) > 100:
warnings.warn(
"DataFrame is highly fragmented. This is usually the result "
"of calling `frame.insert` many times, which has poor performance. "
"Consider using pd.concat instead. To get a de-fragmented frame, "
"use `newframe = frame.copy()`",
PerformanceWarning,
stacklevel=3,
)
self._consolidate_inplace()

def reindex_axis(
self,
Expand Down
14 changes: 0 additions & 14 deletions pandas/tests/frame/indexing/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import numpy as np
import pytest

from pandas.errors import PerformanceWarning

from pandas import DataFrame, Index
import pandas._testing as tm

Expand Down Expand Up @@ -68,15 +66,3 @@ def test_insert_with_columns_dups(self):
[["a", "d", "g"], ["b", "e", "h"], ["c", "f", "i"]], columns=["A", "A", "A"]
)
tm.assert_frame_equal(df, exp)

def test_insert_item_cache(self):
df = DataFrame(np.random.randn(4, 3))
ser = df[0]

with tm.assert_produces_warning(PerformanceWarning):
for n in range(100):
df[n + 3] = df[1] * n

ser.values[0] = 99

assert df.iloc[0, 0] == df[0][0]
0