How to access a bad column name


ROOT Version: 6.34.04
Platform: macOS Sequoia 15.4.1
Compiler: Unknown, from conda


How do I access to or rename a bad column name in an existing RDataFrame? Here is an example of a bad CSV title, “Current[A]”. Of course I can edit the original file but I would like to know a proper way.

In [1]: import ROOT
In [2]: df = ROOT.RDF.FromCSV('data/20250527_151152_HgAg_PDc_0.csv')
In [3]: df.GetColumnNames()
Out[3]: 
vector<string>{ "CurrentActualWavelength", "CurrentNominalWavelength", "Current[A]", "Temp_AirAroundGrating", "Temp_AirAroundPD", "Temp_HgArLightSourceCabinet", "Temp_KEITHLEY6487Cabinet", "Temp_PDSM1Tube", "Time[s] (start=1748326329.7681952)
", "Wavelength[nm]" }

In [4]: df.Define('current', 'Current[A]')
input_line_58:2:21: error: use of undeclared identifier 'Current'
auto func0(){return Current[A]
                    ^
input_line_58:2:29: error: use of undeclared identifier 'A'
auto func0(){return Current[A]
                            ^
libc++abi: terminating due to uncaught exception of type std::runtime_error: 
RDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of the crash
 All RDF objects that have not run an event loop yet should be considered in an invalid state.

 *** Break *** abort
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] (anonymous namespace)::TExceptionHandlerImp::HandleException(int) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libCore.6.34.04.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/usr/lib/system/libsystem_pthread.dylib] pthread_kill (no debug info)
[/usr/lib/system/libsystem_c.dylib] abort (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) (no debug info)
[/usr/lib/libc++abi.dylib] demangling_terminate_handler() (no debug info)
[/usr/lib/libobjc.A.dylib] _objc_terminate() (no debug info)
[/usr/lib/libc++abi.dylib] std::__terminate(void (*)()) (no debug info)
[/usr/lib/libc++abi.dylib] __cxa_get_exception_ptr (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::InterpreterDeclare(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] (anonymous namespace)::DeclareFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::BookDefineJit(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>, ROOT::Detail::RDF::RLoopManager&, ROOT::RDF::RDataSource*, ROOT::Internal::RDF::RColumnRegister const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::shared_ptr<ROOT::Detail::RDF::RNodeBase>*) (no debug info)
[<unknown binary>] (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] WrapperCall(long, unsigned long, void*, void*, void*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] Cppyy::CallO(long, void*, unsigned long, void*, unsigned long) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::InstanceExecutor::Execute(long, void*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteFast(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteProtected(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::Call(CPyCppyy::CPPInstance*&, _object* const*, unsigned long, _object*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::mp_vectorcall(CPyCppyy::CPPOverload*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::SelectAndForward(CPyCppyy::TemplateProxy*, CPyCppyy::CPPOverload*, _object* const*, unsigned long, _object*, bool, bool, unsigned long long, std::__1::vector<CPyCppyy::Utility::PyError_t, std::__1::allocator<CPyCppyy::Utility::PyError_t>>&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::tpp_vectorcall(CPyCppyy::TemplateProxy*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyObject_Vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] builtin_exec (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex2 (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] method_vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyVectorcall_Call (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] run_mod (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_SimpleFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_AnyFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] Py_RunMain (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] pymain_main (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] main (no debug info)
[/usr/lib/dyld] start (no debug info)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 df.Define('current', 'Current[A]')

File ~/anaconda3_arm/envs/lab309/lib/python3.12/site-packages/ROOT/_pythonization/_rdf_pyz.py:372, in _PyDefine(rdf, col_name, callable_or_str, cols, extra_args)
    369     raise TypeError(f"First argument of Define must be a valid string for the new column name. {type(col_name).__name__} is not a string.")
    371 if isinstance(callable_or_str, str): # If string argument is passed. Invoke the Original Define.
--> 372     return rdf._OriginalDefine(col_name, callable_or_str)
    374 if not callable(callable_or_str): # The 2st argument is either a string or a python callable.
    375     raise TypeError(f"The second argument of a Define operation should be a callable. {type(callable_or_str).__name__} object is not callable.")

TypeError: Template method resolution failed:
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::Define(string_view name, string_view expression) =>
    AbortSignal: abort from C++; program state was reset
  Failed to instantiate "Define(ROOT::RDataFrame&,std::string,std::string)"
  Failed to instantiate "Define(ROOT::RDataFrame*,std::string,std::string)"
  Failed to instantiate "Define(ROOT::RDataFrame,std::string,std::string)"

Try with Alias() instead of Define():

import ROOT as r
df = r.RDF.FromCSV('a.csv')
print(df.GetColumnNames())
df = df.Alias('current','Current[A]')
print(df.GetColumnNames())

with this in a.py:

CurrentNom,Current[A],TempC
1.2,1.1,21.0

I get:

$ py a.py 
{ "CurrentNom", "Current[A]", "TempC" }
{ "CurrentNom", "Current[A]", "TempC", "current" }

Checking further, it seems that Alias does not fully solve the issue; adding this at the end:

print(df.Filter('current>0').Count().GetValue())

gives

{ "CurrentNom", "Current[A]", "TempC" }
{ "CurrentNom", "Current[A]", "TempC", "current" }
input_line_53:2:38: error: use of undeclared identifier 'Current'
auto func0(const double var0){return Current[A]>0
                                     ^
input_line_53:2:46: error: use of undeclared identifier 'A'
auto func0(const double var0){return Current[A]>0
                                             ^
Traceback (most recent call last):
  File "/scr/a.py", line 7, in <module>
    print(df.Filter('current>0').Count().GetValue())
...

It looks similar to this

As another option, converting to NumPy may work, even with the original names:

import ROOT as r

df = r.RDF.FromCSV('a.csv')
print(df.GetColumnNames())
df = df.Alias('current','Current[A]')
print(df.GetColumnNames())
#print(df.Filter('current>0').Count().GetValue())
print(df.AsNumpy(['current']))
print(df.AsNumpy(['Current[A]']))

resulting in

{ "CurrentNom", "Current[A]", "TempC" }
{ "CurrentNom", "Current[A]", "TempC", "current" }
{'current': ndarray([1.1])}
{'Current[A]': ndarray([1.1])}

Thank you very much. Alias did work.

But it looks that Define does not handle the aliased column properly. Does it still access the original column name internally? Can I avoid this? If not possible, I would use the NumPy solution.

$ cat test.csv
temperature,current[A]
27.4,2e06
28.9,4e06
29.3,1e06
27.5,5e06
25.2,3e06
27.1,2e06
In [1]: import ROOT
In [2]: df = ROOT.RDF.FromCSV('test.csv')
In [3]: df = df.Alias('current', 'current[A]') # OK
In [4]: df.GetColumnNames()
Out[4]: vector<string>{ "current", "current[A]", "temperature" }
In [5]: df = df.Define('neg_temp', '-temperature') # OK
In [6]: df.GetColumnNames()
Out[6]: vector<string>{ "current", "current[A]", "neg_temp", "temperature" }
In [7]: df = df.Define('neg_current', '-current') # NG
input_line_61:2:39: error: use of undeclared identifier 'current'
auto func1(std::string& var0){return -current[A]
                                      ^
input_line_61:2:47: error: use of undeclared identifier 'A'
auto func1(std::string& var0){return -current[A]
                                              ^
libc++abi: terminating due to uncaught exception of type std::runtime_error: 
RDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of the crash
 All RDF objects that have not run an event loop yet should be considered in an invalid state.

 *** Break *** abort
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] (anonymous namespace)::TExceptionHandlerImp::HandleException(int) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libCore.6.34.04.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/usr/lib/system/libsystem_pthread.dylib] pthread_kill (no debug info)
[/usr/lib/system/libsystem_c.dylib] abort (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) (no debug info)
[/usr/lib/libc++abi.dylib] demangling_terminate_handler() (no debug info)
[/usr/lib/libobjc.A.dylib] _objc_terminate() (no debug info)
[/usr/lib/libc++abi.dylib] std::__terminate(void (*)()) (no debug info)
[/usr/lib/libc++abi.dylib] __cxa_get_exception_ptr (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::InterpreterDeclare(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] (anonymous namespace)::DeclareFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::BookDefineJit(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>, ROOT::Detail::RDF::RLoopManager&, ROOT::RDF::RDataSource*, ROOT::Internal::RDF::RColumnRegister const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::shared_ptr<ROOT::Detail::RDF::RNodeBase>*) (no debug info)
[<unknown binary>] (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] WrapperCall(long, unsigned long, void*, void*, void*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] Cppyy::CallO(long, void*, unsigned long, void*, unsigned long) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::InstanceExecutor::Execute(long, void*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteFast(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteProtected(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::Call(CPyCppyy::CPPInstance*&, _object* const*, unsigned long, _object*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::mp_vectorcall(CPyCppyy::CPPOverload*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::tpp_vectorcall(CPyCppyy::TemplateProxy*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyObject_Vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] builtin_exec (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex2 (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] method_vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyVectorcall_Call (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] run_mod (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_SimpleFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_AnyFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] Py_RunMain (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] pymain_main (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] main (no debug info)
[/usr/lib/dyld] start (no debug info)
input_line_62:2:39: error: use of undeclared identifier 'current'
auto func1(std::string& var0){return -current[A]
                                      ^
input_line_62:2:47: error: use of undeclared identifier 'A'
auto func1(std::string& var0){return -current[A]
                                              ^
libc++abi: terminating due to uncaught exception of type std::runtime_error: 
RDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of the crash
 All RDF objects that have not run an event loop yet should be considered in an invalid state.

 *** Break *** abort
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] (anonymous namespace)::TExceptionHandlerImp::HandleException(int) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libCore.6.34.04.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/usr/lib/system/libsystem_pthread.dylib] pthread_kill (no debug info)
[/usr/lib/system/libsystem_c.dylib] abort (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) (no debug info)
[/usr/lib/libc++abi.dylib] demangling_terminate_handler() (no debug info)
[/usr/lib/libobjc.A.dylib] _objc_terminate() (no debug info)
[/usr/lib/libc++abi.dylib] std::__terminate(void (*)()) (no debug info)
[/usr/lib/libc++abi.dylib] __cxa_get_exception_ptr (no debug info)
[/usr/lib/libc++abi.dylib] __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::InterpreterDeclare(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] (anonymous namespace)::DeclareFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libROOTDataFrame.6.34.04.so] ROOT::Internal::RDF::BookDefineJit(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>, ROOT::Detail::RDF::RLoopManager&, ROOT::RDF::RDataSource*, ROOT::Internal::RDF::RColumnRegister const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::shared_ptr<ROOT::Detail::RDF::RNodeBase>*) (no debug info)
[<unknown binary>] (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] WrapperCall(long, unsigned long, void*, void*, void*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy_backend.6.34.04.so] Cppyy::CallO(long, void*, unsigned long, void*, unsigned long) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::InstanceExecutor::Execute(long, void*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteFast(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::ExecuteProtected(void*, long, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::CPPMethod::Call(CPyCppyy::CPPInstance*&, _object* const*, unsigned long, _object*, CPyCppyy::CallContext*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::(anonymous namespace)::mp_vectorcall(CPyCppyy::CPPOverload*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::SelectAndForward(CPyCppyy::TemplateProxy*, CPyCppyy::CPPOverload*, _object* const*, unsigned long, _object*, bool, bool, unsigned long long, std::__1::vector<CPyCppyy::Utility::PyError_t, std::__1::allocator<CPyCppyy::Utility::PyError_t>>&) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/lib/libcppyy.6.34.04.so] CPyCppyy::tpp_vectorcall(CPyCppyy::TemplateProxy*, _object* const*, unsigned long, _object*) (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyObject_Vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] builtin_exec (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex2 (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] gen_send_ex (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] method_vectorcall (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyVectorcall_Call (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyEval_EvalFrameDefault (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] PyEval_EvalCode (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] run_mod (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_SimpleFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] _PyRun_AnyFileObject (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] Py_RunMain (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] pymain_main (no debug info)
[/Users/oxon/anaconda3_arm/envs/lab309/bin/python3.12] main (no debug info)
[/usr/lib/dyld] start (no debug info)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 df = df.Define('neg_current', '-current')

File ~/anaconda3_arm/envs/lab309/lib/python3.12/site-packages/ROOT/_pythonization/_rdf_pyz.py:372, in _PyDefine(rdf, col_name, callable_or_str, cols, extra_args)
    369     raise TypeError(f"First argument of Define must be a valid string for the new column name. {type(col_name).__name__} is not a string.")
    371 if isinstance(callable_or_str, str): # If string argument is passed. Invoke the Original Define.
--> 372     return rdf._OriginalDefine(col_name, callable_or_str)
    374 if not callable(callable_or_str): # The 2st argument is either a string or a python callable.
    375     raise TypeError(f"The second argument of a Define operation should be a callable. {type(callable_or_str).__name__} object is not callable.")

TypeError: Template method resolution failed:
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::Define(string_view name, string_view expression) =>
    AbortSignal: abort from C++; program state was reset
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::Define(string_view name, string_view expression) =>
    AbortSignal: abort from C++; program state was reset
  Failed to instantiate "Define(ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>&,std::string,std::string)"
  Failed to instantiate "Define(ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>*,std::string,std::string)"
  Failed to instantiate "Define(ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>,std::string,std::string)"

It seems so. Maybe @mczurylo or @vpadulan can help here.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.