def operate(elems, units, inplace_units=False, unitdict=None, key=None,
    operation='+'):
    """
    Operate on elements considering their units

    Parameters
    -----------
    elems: list, tuple
        list of pandas.Series
    units: list, tuple
        list of pint.units ordered as the elems list
    inplace_units: bool
        sets dictionary inplace_units
    unitdict: dict
        dict to be set inplace
    key: str
        name of variables to be set inplace as dict key
    """
    import pandas as pd
    import numpy as np
    idx = elems[0].index
    if operation == '+':
        result = elems[0].values * units[0]
        for elem, unit in zip(elems[1:], units[1:]):
            if type(elem) == pd.Series:
                elem = elem.reindex(idx)
                result += elem.values * unit
            else:
                result += elem * unit
    if operation == '*':
        result = elems[0].values * units[0]
        for elem, unit in zip(elems[1:], units[1:]):
            if type(elem) == pd.Series:
                elem = elem.reindex(idx)
                result *= elem.values * unit
            else:
                result *= elem * unit
    if operation == '/':
        result = elems[0].values * units[0]
        for elem, unit in zip(elems[1:], units[1:]):
            if type(elem) == pd.Series:
                elem = elem.reindex(idx)
                result /= elem.values * unit
            else:
                result /= elem * unit
    out = pd.Series(result.magnitude, index=idx)
    funit = result.units
    if inplace_units == True:
        unitdict.update({key: funit})
        return out
    else:
        return out, funit
