Re: package extension problem

2012-02-13 Thread Terry Reedy
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, f

Re: package extension problem

2012-02-13 Thread Peter Otten
Fabrizio Pollastri wrote: > Ok. To be more clear, consider the real python package Pandas. > > This package defines a Series class and a DataFrame class. > The DataFrame is a matrix that can have columns of > different type. > > If I write > > import pandas as pd > df = pd.DataFrame({'A':[1,2,3

Re: package extension problem

2012-02-13 Thread Jerry Hill
On Sun, Feb 12, 2012 at 1:46 PM, Fabrizio Pollastri wrote: > Hello, > > I wish to extend the functionality of an existing python package by > creating > a new package that redefines the relevant classes of the old package. Each > new class inherits the equivalent old class and adds new methods. >

Re: package extension problem

2012-02-13 Thread Miki Tebeka
> 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. -- http://mail.python.org/mailman/listinfo/python-list

Re: package extension problem

2012-02-13 Thread Fabrizio Pollastri
Ok. To be more clear, consider the real python package Pandas. This package defines a Series class and a DataFrame class. The DataFrame is a matrix that can have columns of different type. If I write import pandas as pd df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]}) a data frame with two cols na

Re: package extension problem

2012-02-13 Thread Miki Tebeka
> B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. I don't understand this sentence. How does B[some_hash] related to A? I've tried the below and it seems to work. Can you paste some code to help us understand more? -- old.py -- class A: