Skip to content Skip to sidebar Skip to footer

Pandas Select Unique Values From Column

I was able to ingest a csv in jupyter notes by doing this : csvData= pd.read_csv('logfile.csv') My data looks like this: event_timestamp ip url 2018-01-10 00:00 111.111.111.111

Solution 1:

You need to select the column correctly then apply unique

csvData['ip'].unique().tolist()
Out[677]: ['111.111.111.111', '222.222.222.222']

Solution 2:

The reason why you are running into this problem is because pd.read_csv("logfile.csv").unique() is not a valid attribute from DataFrame. What I suggest you do is since csvData comes out as a list, you can search for all ip's by csvData['ip'] then search for unique ip's with csvData['ip'].unique().


Post a Comment for "Pandas Select Unique Values From Column"