ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Oct 2016 07:41:36 -0500sage vs. python integers and floats in pandas, matplotlib etc.http://ask.sagemath.org/question/35270/sage-vs-python-integers-and-floats-in-pandas-matplotlib-etc/ 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!
stanThu, 27 Oct 2016 07:41:36 -0500http://ask.sagemath.org/question/35270/Difficulties evaluating an expression stringhttp://ask.sagemath.org/question/10959/difficulties-evaluating-an-expression-string/For some recent computations, I devolved some initial calculus to the Maxima sub-system, and I've ended up with a list `eqs` of Maxima expressions. I want to transfer this list out of Maxima. This works:
sage: eqs2 = [repr(xx) for xx in eqs]
but gives me strings, which are not useful. And this:
sage: eqs2 = [sage_eval(repr(xx)) for xx in eqs]
returns the error message
NameError: name 'a43' is not defined
which is strange, as it is defined as a variable:
sage: a43
a43
I could create a list of local variables:
vars = {'a21':a21,'a31':a31}
and so on, and use
sage_eval(xx,vars)
but as there are 20 more variables, this would be tedious.
Is there a better way?
AlasdairFri, 24 Jan 2014 13:17:42 -0600http://ask.sagemath.org/question/10959/