Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20359
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: package extension problem |
| Date | 2012-02-13 14:12 -0500 |
| References | <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <mailman.5765.1329155611.27778.python-list@python.org> <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5771.1329160386.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
package extension problem Fabrizio Pollastri <f.pollastri@inrim.it> - 2012-02-12 19:46 +0100
Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:18 -0800
Re: package extension problem Fabrizio Pollastri <f.pollastri@inrim.it> - 2012-02-13 18:53 +0100
Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:58 -0800
Re: package extension problem Terry Reedy <tjreedy@udel.edu> - 2012-02-13 14:12 -0500
Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:58 -0800
Re: package extension problem Peter Otten <__peter__@web.de> - 2012-02-13 19:28 +0100
Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:18 -0800
csiph-web