A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/commit/dca3c5c5a6a3769ee01465baca04cfdfa66a4f76 below:

get_dtype_counts publicized and added dtypes property · pandas-dev/pandas@dca3c5c · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+17

-3

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+17

-3

lines changed Original file line number Diff line number Diff line change

@@ -13,6 +13,10 @@ pandas 0.4.1

13 13 14 14

This is a bug fix release

15 15 16 +

**New features / modules**

17 + 18 +

- Added new `DataFrame` methods `get_dtype_counts` and property `dtypes`

19 + 16 20

**Bug fixes**

17 21 18 22

- Fixed DataFrame constructor bug causing downstream problems (e.g. .copy()

Original file line number Diff line number Diff line change

@@ -648,19 +648,23 @@ def info(self, verbose=True, buf=None):

648 648

% (_stringify(cols[0]),

649 649

_stringify(cols[-1])))

650 650 651 -

counts = self._get_dtype_counts()

651 +

counts = self.get_dtype_counts()

652 652

dtypes = ['%s(%d)' % k for k in sorted(counts.iteritems())]

653 653

buf.write(u'dtypes: %s' % ', '.join(dtypes))

654 654 655 -

def _get_dtype_counts(self):

655 +

@property

656 +

def dtypes(self):

657 +

return self.apply(lambda x: x.dtype)

658 + 659 +

def get_dtype_counts(self):

656 660

counts = {}

657 661

for _, series in self.iteritems():

658 662

if series.dtype in counts:

659 663

counts[series.dtype] += 1

660 664

else:

661 665

counts[series.dtype] = 1

662 666 663 -

return counts

667 +

return Series(counts)

664 668 665 669

#----------------------------------------------------------------------

666 670

# properties for index and columns

Original file line number Diff line number Diff line change

@@ -1543,6 +1543,12 @@ def test_info(self):

1543 1543

self.frame.info(buf=io)

1544 1544

self.tsframe.info(buf=io)

1545 1545 1546 +

def test_dtypes(self):

1547 +

self.mixed_frame['bool'] = self.mixed_frame['A'] > 0

1548 +

result = self.mixed_frame.dtypes

1549 +

expected = self.mixed_frame.dtypes

1550 +

assert_series_equal(result, expected)

1551 + 1546 1552

def test_append(self):

1547 1553

begin_index = self.frame.index[:5]

1548 1554

end_index = self.frame.index[5:]

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4