How does `DataBlock` knows the way to read `DataFrame`?

also, in Chapter6, we create an empty DataBlock like below.

dblock = DataBlock()

and pass a pandas DataFrame to the datasets method.

dsets = dblock.datasets(df)

then, looks like dsets already knows how to read the df because it prints out information included in the DataFrame.

However, according to the internal source code from the datasets method (below), when get_items is not set, it does nothing (noop). And this is the case I guess.

 def datasets(self, source, verbose=False):
        self.source = source
        items = (self.get_items or noop)(source)

How does DataBlock knows the way to read DataFrame?

def noop (x=None, *args, **kwargs):
“Do nothing”
return x

While noop does nothing to the data, it does pass it through the function and returns it

items = noop(source)
items = source after the “noop”

1 Like