Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'instance,': 0.05; 'override': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'attribute.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subclass': 0.09; 'essentially': 0.10; 'def': 0.13; 'case.': 0.15; 'reedy': 0.16; 'subject:package': 0.16; 'wrote:': 0.18; 'int': 0.18; 'subject:problem': 0.19; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'tests': 0.25; 'import': 0.27; "i'm": 0.28; 'class': 0.29; 'problem': 0.29; 'pm,': 0.29; 'familiar': 0.32; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'header:X-Complaints-To:1': 0.34; 'to:addr:python-list': 0.35; '...': 0.35; 'received:org': 0.36; 'but': 0.37; 'skip:_ 10': 0.38; 'change': 0.40; 'might': 0.40; 'to:addr:python.org': 0.40; "you'll": 0.61; 'skip:n 30': 0.64; 'other):': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: package extension problem Date: Mon, 13 Feb 2012 14:12:44 -0500 References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329160386 news.xs4all.nl 6990 [2001:888:2000:d::a6]:56874 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20359 On 2/13/2012 12:58 PM, Miki Tebeka wrote: >> import new_pandas as np df = >> np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) col_A = df['A'] > I'm not familiar with pandas, but my *guess* will be that you'll need > to override __getitem__ in the new DataFrame. This is essentially the same problem that if you, for instance, subclass int as myint, you need to override (wrap) *every* method to get them to return myints instead of ints. class myint(int): ... def __add__(self, other): return myint(self+other) .... In the OP's case, if the original class is in python, one might be able to just change the __class__ attribute. But I would make sure to have a good set of tests in any case. -- Terry Jan Reedy