Search code examples
pythonpandasdatatable

"NameError: name 'update' is not defined" Error when using datatable


I am trying datatable in python for first time and was following examples from this link: Grouping with by() to explore more on datatables, but am getting a NameError when attempted below code.

import numpy as np
import pandas as pd
import datatable as dt

df = dt.Frame([[1, 1, 5], [2, 3, 6]], names=['A', 'B'])

df[:, update(filter_col = count()), by('A')]

Error:

--------------------------------------------------------------------------- NameError                                 Traceback (most recent call
last) ~\AppData\Local\Temp/ipykernel_2040/2701559568.py in <module>
----> 1 df[:, update(filter_col = count()), by('A')]

NameError: name 'update' is not defined

This is working fine in the example shown in above link but I am not sure why I am getting this error. Also tried help on this:

help(update())

But got this error:

--------------------------------------------------------------------------- NameError                                 Traceback (most recent call
last) ~\AppData\Local\Temp/ipykernel_2040/1402169417.py in <module>
----> 1 help(update())

NameError: name 'update' is not defined

Solution

  • The function update is not imported directly, but through datatable (dt). You can access it withdt.update.