python DataFrame: get 'set' from DataFrame elements -


how can 'set' data dataframe elements?

for example, if have data as

df = dataframe([['a','b','z'], ['a', 'c'], ['d']]) 

i

{'a', 'b', 'c', 'd', 'z'} 

(type: set)

if use sentence, can code it. however, if there way calculate pandas, use it.

dataframe.stack(dropna=true) per default drops nans

in [56]: df.stack().tolist() out[56]: ['a', 'b', 'z', 'a', 'c', 'd'] 

or set:

in [57]: set(df.stack().tolist()) out[57]: {'a', 'b', 'c', 'd', 'z'} 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -