>>> import pandas as pd
>>> from sympy.abc import x, y
>>> gg = pd.DataFrame([[1,2],[3,3],[4,5]], columns=[x,y])
>>> print(gg[[x]]) # works fine, but returns a DataFrame
x
0 1
1 3
2 4
>>> print(gg[x])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...\pandas\core\frame.py", line 1941, in __getitem__
key = com._apply_if_callable(key, self)
File "...\pandas\core\common.py", line 441, in _apply_if_callable
return maybe_callable(obj, **kwargs)
File "...sympy\core\symbol.py", line 158, in __call__
return Function(self.name)(*args)
File "...\sympy\core\function.py", line 761, in __new__
obj = super(AppliedUndef, cls).__new__(cls, *args, **options)
File "...\sympy\core\function.py", line 431, in __new__
pr = max(cls._should_evalf(a) for a in result.args)
File "...\sympy\core\function.py", line 431, in <genexpr>
pr = max(cls._should_evalf(a) for a in result.args)
File "...\sympy\core\function.py", line 449, in _should_evalf
if arg.is_Float:
File "...\pandas\core\generic.py", line 3081, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'is_Float'
>>> gg[[x]].iloc[:,0] # super uncomfortable...
0 1
1 3
2 4
Name: x, dtype: int64
>>> fg = pd.DataFrame([[1,2],[3,3],[4,5]], columns=[f,g])
>>> fg[[f]]
<function f at 0x000000000F79BEB8>
0 1
1 3
2 4
>>> fg[f]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...\pandas\core\frame.py", line 1941, in __getitem__
key = com._apply_if_callable(key, self)
File "...\pandas\core\common.py", line 441, in _apply_if_callable
return maybe_callable(obj, **kwargs)
TypeError: f() takes no arguments (1 given)
:
z = x * log(y)
smart_func(df, z)
print(df[z])