Search all different elements of a column (pandas)

Asked

Viewed 1,716 times

0

I developed this part with the functions learned in the classroom

#importando pandas
import pandas as pd
#criando o dataframe
base = pd.read_csv('C:\\Users\\lsilv\\Desktop\\acessos.csv')
#renomeei as colunas para ficar mais fácil de usar
base.columns = ['login', 'plain', 'ip', 'lip', 'mpid', 'tls', 'session']

as I do now to display only the values as in the example below :

'login' 'plain'   'IP'    'lip' 
-------------------------------
dadosx  dadosx     ip1    a;b;c     
dados1  dados2     ip1    a;c      
dados1  dados2     ip2    a         
dados1  dados2     ip3    a ;b       
dados1  dados2     ip4    a;b;c;d  
dados1  dados2     ip1    a;b    
dados1  dados2     ip4    a;b
dados1  dados2     ip9    a;b
dados1  dados2     ip7    a;b    

/>outworking

   'IP'     
---------
   ip1        
   ip2         
   ip3        
   ip4    
   ip9
   ip7      

I have already separated the column I need with the base function.

base.loc[(base["ip"])]

1 answer

0


Usa unique() in the column, base["ip"].unique()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.