def _nbcols(data):
    """ retrieve the number of columns of an object
    
    Example
    -------
    >>> df = pd.DataFrame({"a":np.arange(10),"b":["aa","bb","cc"]*3+["dd"]})
    >>> assert _nbcols(df) == 2
    >>> assert _nbcols(df.values) == 2
    >>> assert _nbcols(df["a"]) == 1
    >>> assert _nbcols(df["a"].values) == 1
    """
    s = getattr(data, 'shape', None)
    if s is None:
        return 1
    elif len(s) == 1:
        return 1
    else:
        return s[1]
