Skip to content

Commit 7b484e0

Browse files
committed
BUG: raise exception in DataFrame.fillna when axis=1 and pass dict/Series. close #1485
1 parent 7bc6455 commit 7b484e0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,11 @@ def fillna(self, value=None, method='pad', axis=0, inplace=False,
27502750
if len(self.columns) == 0:
27512751
return self
27522752
if isinstance(value, (dict, Series)):
2753+
if axis == 1:
2754+
raise NotImplementedError('Currently only can fill '
2755+
'with dict/Series column '
2756+
'by column')
2757+
27532758
result = self if inplace else self.copy()
27542759
for k, v in value.iteritems():
27552760
if k not in result:

pandas/tests/test_frame.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
import cPickle as pickle
66
import operator
77
import os
8-
import sys
98
import unittest
109

1110
import nose
1211

1312
from numpy import random, nan
14-
from numpy.random import randn, randint
13+
from numpy.random import randn
1514
import numpy as np
1615
import numpy.ma as ma
1716

@@ -3868,6 +3867,9 @@ def test_fillna_dict_series(self):
38683867
expected = df.fillna(df.max().to_dict())
38693868
assert_frame_equal(result, expected)
38703869

3870+
# disable this for now
3871+
self.assertRaises(Exception, df.fillna, df.max(1), axis=1)
3872+
38713873
def test_fillna_columns(self):
38723874
df = DataFrame(np.random.randn(10, 10))
38733875
df.values[:, ::2] = np.nan

0 commit comments

Comments
 (0)