Skip to content

Commit d270af9

Browse files
committed
BUG: don't plot empty columns as an array of zeros close #1696
1 parent bd13307 commit d270af9

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

RELEASE.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pandas 0.8.2
7676
- Hack to support storing data with a zero-length axis in HDFStore (#1707)
7777
- Fix DatetimeIndex tz-aware range generation issue (#1674)
7878
- Fix method='time' interpolation with intraday data (#1698)
79+
- Don't plot all-NA DataFrame columns as zeros (#1696)
7980

8081
pandas 0.8.1
8182
============

pandas/core/strings.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,21 @@ def str_decode(arr, encoding):
606606
f = lambda x: x.decode(encoding)
607607
return _na_map(f, arr)
608608

609+
def str_encode(arr, encoding):
610+
"""
611+
Encode character string to unicode using indicated encoding
612+
613+
Parameters
614+
----------
615+
encoding : string
616+
617+
Returns
618+
-------
619+
encoded : array
620+
"""
621+
f = lambda x: x.encode(encoding)
622+
return _na_map(f, arr)
623+
609624
def _noarg_wrapper(f):
610625
def wrapper(self):
611626
result = f(self.series)
@@ -728,6 +743,11 @@ def decode(self, encoding):
728743
result = str_decode(self.series, encoding)
729744
return self._wrap_result(result)
730745

746+
@copy(str_encode)
747+
def encode(self, encoding):
748+
result = str_encode(self.series, encoding)
749+
return self._wrap_result(result)
750+
731751
count = _pat_wrapper(str_count, flags=True)
732752
startswith = _pat_wrapper(str_startswith)
733753
endswith = _pat_wrapper(str_endswith)

pandas/tests/test_strings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,9 @@ def test_match_findall_flags(self):
658658
result = data.str.contains(pat, flags=re.IGNORECASE)
659659
self.assertEquals(result[0], True)
660660

661-
def test_decode(self):
662-
series = Series(['a', 'b', '\xc3\xa4'])
661+
def test_encode_decode(self):
662+
base = Series([u'a', u'b', u'\xe4'])
663+
series = base.str.encode('utf-8')
663664

664665
f = lambda x: x.decode('utf-8')
665666
result = series.str.decode('utf-8')

pandas/tools/plotting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ def _iter_data(self):
551551
columns = df.columns
552552

553553
for col in columns:
554-
empty = df[col].count() == 0
555-
# is this right?
556-
values = df[col].values if not empty else np.zeros(len(df))
557-
554+
# # is this right?
555+
# empty = df[col].count() == 0
556+
# values = df[col].values if not empty else np.zeros(len(df))
558557

558+
values = df[col].values
559559
yield col, values
560560

561561
@property

0 commit comments

Comments
 (0)