nctoolkit.DataSet.drop

DataSet.drop(self, \*\*kwargs)

Remove variables This will remove stated variables from files in the dataset.

Parameters
  • *kwargs

    Possible arguments: var, year, month, day

    Note: this uses partial matches. So years, month, variable etc. will also work

  • kwarg works as follows (Each) –

  • var (str or list) – A variable or list of variables to select. This method will accept wild cards. So using ‘var*’ would select all variables beginning with ‘var’.

  • day (list, range or int) – Day(s) to drop.

  • month (list, range or int) – Month(s) to drop.

  • year (list, range or int) – Year(s) to drop.

  • time (list, range or int) – Time steps to to drop. This can include negative indices.

Examples

If you wanted to remove a single variable ‘var1’ from a dataset data, you would do the following:

>>> ds.drop(variable = 'var')

If you wanted to remove a list of variables, you would do the following:

>>> ds.drop(variable = ['var1', 'var2', 'var2'])

If you wanted to remove the 29th Feburary you would do the following:

>>> ds.drop(month = 2, day = 29)