Skip to content

BUG: Raise TypeError only if key DataFrame is not empty #10126 #10196

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

Conversation

rekcahpassyla
Copy link
Contributor

Proposed fix for #10126

@jreback
Copy link
Contributor

jreback commented May 22, 2015

change this to close issue #10126 instead

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels May 22, 2015
@jreback jreback added this to the 0.17.0 milestone May 22, 2015
@@ -794,6 +794,24 @@ def test_setitem_empty(self):
result.loc[result.b.isnull(), 'a'] = result.a
assert_frame_equal(result, df)

def test_setitem_empty_frame_with_boolean(self):
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the issue number here as a comment

@rekcahpassyla rekcahpassyla force-pushed the error_setting_empty_df_boolean branch from ba7b437 to a0ce8ed Compare May 22, 2015 14:29
@rekcahpassyla rekcahpassyla changed the title BUG: Raise TypeError only if key DataFrame is not empty #10195 BUG: Raise TypeError only if key DataFrame is not empty #10126 May 22, 2015
@rekcahpassyla
Copy link
Contributor Author

@jreback Requested changes made and squashed, changed title to reference #10126

df = pd.DataFrame([[2, 2]], index=pd.DatetimeIndex(['2011-01-01']))
df2 = pd.DataFrame([[1, 1]], index=pd.DatetimeIndex(['2011-01-01']))

df[df > df2] = 47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the first part of this test (e.g. before the loop), its just confusing.

@rekcahpassyla
Copy link
Contributor Author

Using is_bool_dtype results in a couple of extra test failures- investigating.

======================================================================
FAIL: test_setitem_boolean (pandas.tests.test_frame.TestDataFrame)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\dev\code\opensource\pandas-rekcahpassyla\pandas\tests\test_frame.py", line 621, in test_setitem_boolean
    df[df * 0] = 2
  File "c:\dev\code\opensource\pandas-rekcahpassyla\pandas\util\testing.py", line 1640, in __exit__
    raise AssertionError("{0} not raised.".format(name))
AssertionError: TypeError not raised.

======================================================================
FAIL: test_frame_getitem_setitem_boolean (pandas.tests.test_multilevel.TestMultiLevel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\dev\code\opensource\pandas-rekcahpassyla\pandas\tests\test_multilevel.py", line 354, in test_frame_getitem_setitem_boolean
    df[df * 0] = 2
  File "c:\dev\code\opensource\pandas-rekcahpassyla\pandas\util\testing.py", line 1640, in __exit__
    raise AssertionError("{0} not raised.".format(name))
AssertionError: TypeError not raised.

@rekcahpassyla rekcahpassyla force-pushed the error_setting_empty_df_boolean branch 2 times, most recently from b8b3e4c to dcda77e Compare May 22, 2015 15:23
@rekcahpassyla
Copy link
Contributor Author

Fixed my obvious silly mistake. (Doh)

]:
df2 = df.copy()
df[df > df2] = 47

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need an assert_frame_equal here to make that the assignment is correct.

@rekcahpassyla rekcahpassyla force-pushed the error_setting_empty_df_boolean branch 2 times, most recently from c2cb4da to c5d99b7 Compare May 26, 2015 12:40
@jreback
Copy link
Contributor

jreback commented Jun 2, 2015

ok, looks good. pls add a release mentioning the original issue.

@jreback jreback modified the milestones: 0.16.2, 0.17.0 Jun 2, 2015
@rekcahpassyla rekcahpassyla force-pushed the error_setting_empty_df_boolean branch from c5d99b7 to f8e7c93 Compare June 3, 2015 10:08
@rekcahpassyla
Copy link
Contributor Author

Rebased and added release note to 0.16.2, in the bug fix section.

shoyer added a commit that referenced this pull request Jun 3, 2015
…oolean

BUG: Raise TypeError only if key DataFrame is not empty #10126
@shoyer shoyer merged commit e182793 into pandas-dev:master Jun 3, 2015
@shoyer
Copy link
Member

shoyer commented Jun 3, 2015

thanks!

@shoyer shoyer mentioned this pull request Jun 3, 2015
@rekcahpassyla
Copy link
Contributor Author

Thank you!

@rekcahpassyla rekcahpassyla deleted the error_setting_empty_df_boolean branch June 3, 2015 22:38
@jorisvandenbossche
Copy link
Member

Since this is merged in master, all travis builds seem to fail (although the tests for the PR itself were green):

FAIL: test_sum (pandas.tests.test_series.TestSeries)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/tests/test_series.py", line 2319, in test_sum
    self._check_stat_op('sum', np.sum)
  File "/home/travis/build/pydata/pandas/pandas/tests/test_series.py", line 2683, in _check_stat_op
    testit()
  File "/home/travis/build/pydata/pandas/pandas/tests/test_series.py", line 2656, in testit
    self.assertTrue(np.isnan(f(allna)))
AssertionError: False is not true

@jorisvandenbossche
Copy link
Member

Ah, caused by bottleneck upgrade: #10270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants