Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

coercion in pandas?

I have run into a problem before, where e.g. matplotlib did not like sage floats as input for axes ranges and I had to wrap them all in np.float(). Now I found a similar problem with pandas:

import pandas as pd  
fname = 'blah.xlsx'  
data_inf = pd.read_excel(fname)
# This works:
print data_inf[:int(3)]
# This does not:
print data_inf[:3]

TypeError: cannot do slice indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [3] of <type 'sage.rings.integer.Integer'>

Is there a way to set up proper parsing for the worksheet at the onset, so that I don't have to wrap numbers and variables in the specific type needed by the respective function every time?

Thanks for your help!

coercion in pandas?

I have run into a problem before, where e.g. matplotlib did not like sage floats as input for axes ranges and I had to wrap them all in np.float(). Now I found a similar problem with pandas:

import pandas as pd  
fname = 'blah.xlsx'  
data_inf = pd.read_excel(fname)
# This works:
print data_inf[:int(3)]
# This does not:
print data_inf[:3]

TypeError: cannot do slice indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [3] of <type 'sage.rings.integer.Integer'>

Is there a way to set up proper parsing for the worksheet at the onset, so that I don't have to wrap numbers and variables in the specific type needed by the respective function every time?

Thanks for your help!