Python - Efficiently find the set of all characters in a pandas DataFrame?
Question: I want to find the set of all unique characters contained within a pandas
DataFrame. One solution that works is given below:

    
    
    from operator import add
    set(reduce(add, map(unicode, df.values.flatten())))
    

However, the solution above takes a long time with large DataFrames. What are
more efficient ways of doing this?

I am trying to find all unique characters in a pandas DataFrame so I can
choose an appropriate delimiter when writing the DataFrame to disk as a csv.


Answer: Learned this from Jeff
[here](http://stackoverflow.com/questions/20084382/unique-values-in-a-pandas-
dataframe)

This should be doable using Pandas built-ins:

    
    
    a = pd.DataFrame( data=np.random.randint(0,100000,(1000000,20)))
    
    # now pull out unique values (less than a second for 2E7 data points)
    b = pd.unique( a.values.ravel() )
    

