Skip to content

Fixturize tests/frame/test_mutate_columns.py #25642

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 1 commit into from
Mar 10, 2019
Merged
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
25 changes: 12 additions & 13 deletions pandas/tests/frame/test_mutate_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
from pandas.compat import PY36, lrange, range

from pandas import DataFrame, Index, MultiIndex, Series
from pandas.tests.frame.common import TestData
import pandas.util.testing as tm
from pandas.util.testing import assert_frame_equal

# Column add, remove, delete.


class TestDataFrameMutateColumns(TestData):
class TestDataFrameMutateColumns():

def test_assign(self):
df = DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
Expand Down Expand Up @@ -193,9 +192,9 @@ def test_insert(self):
exp = DataFrame(data={'X': ['x', 'y', 'z']}, index=['A', 'B', 'C'])
assert_frame_equal(df, exp)

def test_delitem(self):
del self.frame['A']
assert 'A' not in self.frame
def test_delitem(self, float_frame):
del float_frame['A']
assert 'A' not in float_frame

def test_delitem_multiindex(self):
midx = MultiIndex.from_product([['A', 'B'], [1, 2]])
Expand Down Expand Up @@ -223,16 +222,16 @@ def test_delitem_multiindex(self):
with pytest.raises(KeyError):
del df['A']

def test_pop(self):
self.frame.columns.name = 'baz'
def test_pop(self, float_frame):
float_frame.columns.name = 'baz'

self.frame.pop('A')
assert 'A' not in self.frame
float_frame.pop('A')
assert 'A' not in float_frame

self.frame['foo'] = 'bar'
self.frame.pop('foo')
assert 'foo' not in self.frame
assert self.frame.columns.name == 'baz'
float_frame['foo'] = 'bar'
float_frame.pop('foo')
assert 'foo' not in float_frame
assert float_frame.columns.name == 'baz'

# gh-10912: inplace ops cause caching issue
a = DataFrame([[1, 2, 3], [4, 5, 6]], columns=[
Expand Down