<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write_header(data, fp, relation_name, index):
 """Write header containing attribute names and types"""

    fp.write("@relation {0}\n\n".format(relation_name))

    if index:
        data = data.reset_index()

    attribute_names = _sanitize_column_names(data)

    for column, series in data.iteritems():
        name = attribute_names[column]
        fp.write("@attribute {0}\t".format(name))

        if is_categorical_dtype(series) or is_object_dtype(series):
            _write_attribute_categorical(series, fp)
        elif numpy.issubdtype(series.dtype, numpy.floating):
            fp.write("real")
        elif numpy.issubdtype(series.dtype, numpy.integer):
            fp.write("integer")
        elif numpy.issubdtype(series.dtype, numpy.datetime64):
            fp.write("date 'yyyy-MM-dd HH:mm:ss'")
        else:
            raise TypeError('unsupported type %s' % series.dtype)

        fp.write("\n")
    return data