To_CSV unique values of a pandas column
Question: When I use the following:

    
    
    import pandas as pd
    data = pd.read_csv('C:/Users/Z/OneDrive/Python/Exploratory Data/Aramark/ARMK.csv')
    x = data.iloc[:,2]
    y = pd.unique(x)
    y.to_csv('yah.csv')
    

I get the following error:

    
    
    AttributeError: 'numpy.ndarray' object has no attribute 'to_csv'
    


Answer: IIUC, starting from a dataframe:

    
    
    df = pd.DataFrame({'a':[1,2,3,4,5,6],'b':['a','a','b','c','c','b']})
    

you can get the unique values of a column with:

    
    
    g = df['b'].unique()
    

that returns an array:

    
    
    array(['a', 'b', 'c'], dtype=object)
    

to save it into a .csv file I would transform it into a `Series` s:

    
    
    In [22]: s = pd.Series(g)
    
    In [23]: s
    Out[23]: 
    0    a
    1    b
    2    c
    dtype: object
    

So you can easily save it:

    
    
    In [24]: s.to_csv('file.csv')
    

Hope that helps.

