Pandas select unique values from column

前端 未结 2 892
暖寄归人
暖寄归人 2020-12-19 03:49

I was able to ingest a csv in jupyter notes by doing this :

csvData= pd.read_csv(\"logfile.csv\")

My data looks like this:

         


        
相关标签:
2条回答
  • 2020-12-19 04:43

    You need to select the column correctly then apply unique

    csvData['ip'].unique().tolist()
    Out[677]: ['111.111.111.111', '222.222.222.222']
    
    0 讨论(0)
  • 2020-12-19 04:45

    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().

    0 讨论(0)
提交回复
热议问题