<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_orders(events, sell_delay=5, sep=','):
 """Generate CSV orders based on events indicated in a DataFrame Arguments: events (pandas.DataFrame):
 Table of NaNs or 1's, one column for each symbol. 1 indicates a BUY event. -1 a SELL event. nan or 0 is a nonevent. sell_delay (float):
 Number of days to wait before selling back the shares bought sep (str or None):
 if sep is None, orders will be returns as tuples of `int`s, `float`s, and `str`s otherwise the separator will be used to join the order parameters into the yielded str Returns: generator of str: yielded CSV rows in the format (yr, mo, day, symbol, Buy/Sell, shares) """

    sell_delay = float(unicode(sell_delay)) or 1
    for i, (t, row) in enumerate(events.iterrows()):
        for sym, event in row.to_dict().iteritems():
            # print sym, event, type(event)
            # return events
            if event and not np.isnan(event):
                # add a sell event `sell_delay` in the future within the existing `events` DataFrame
                # modify the series, but only in the future and be careful not to step on existing events
                if event > 0:
                    sell_event_i = min(i + sell_delay, len(events) - 1)
                    sell_event_t = events.index[sell_event_i]
                    sell_event = events[sym][sell_event_i]
                    if np.isnan(sell_event):
                        events[sym][sell_event_t] = -1
                    else:
                        events[sym][sell_event_t] += -1
                order = (t.year, t.month, t.day, sym, 'Buy' if event > 0 else 'Sell', abs(event) * 100)
                if isinstance(sep, basestring):
                    yield sep.join(order)
                yield order