<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_array(self, fields=None, axis=0):
 """Returns an `numpy.ndarray` of self in which the fields are included as an extra dimension. Parameters fields : {None, (list of) strings} The fields to get. All of the fields must have the same datatype. If None, will try to return all of the fields. axis : {0, int} Which dimension to put the fields in in the returned array. For example, if `self` has shape `(l,m,n)` and `k` fields, the returned array will have shape `(k,l,m,n)` if `axis=0`, `(l,k,m,n)` if `axis=1`, etc. Setting `axis=-1` will put the fields in the last dimension. Default is 0. Returns ------- numpy.ndarray The desired fields as a numpy array. """

        if fields is None:
            fields = self.fieldnames
        if isinstance(fields, string_types):
            fields = [fields]
        return numpy.stack([self[f] for f in fields], axis=axis)