Hello,
Is anyone able to tell me what happens in the Lambda function which is used to preprocess the AUS2200 files?
e.g
preprocess=lambda x: x[‘***’]
Hello,
Is anyone able to tell me what happens in the Lambda function which is used to preprocess the AUS2200 files?
e.g
preprocess=lambda x: x[‘***’]
Hi Kim
preprocess functions can be used when concatenating multiple data files together. The preprocess function is applied to each dataset (e.g. the data from a single file) prior to the concatenation occurring. For example, to retrieve one variable from files with multple variables per file, a preprocess function could select only the required data before the concatenation occurs (and therefore be faster than concatenating all the data before select the variable of interest).
A lambda function is a function written in a single line
Hi Anton,
Thanks for your reply. I have use preprocessing before where I have defined my own preprocessing functions, but ‘lambda’ seems to be a predefined function and I can’t find exactly what it does?
It’s a shortcut for an inline function definition.
open_dataset(..., preprocess=lambda x: x[‘***’])
is the same as
def my_preprocess(x):
return x['***']
open_dataset(..., preprocess=my_preprocess)
with the advantage you don’t need to create a separate function elsewhere in the file.
Thanks!