Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'column': 0.07; 'subject:two': 0.07; 'subject:fields': 0.09; 'cc:addr :python-list': 0.11; 'csv': 0.16; 'duplicates': 0.16; 'grouped': 0.16; 'objects.': 0.16; 'subject:compare': 0.16; 'supplying': 0.16; 'subject:python': 0.16; 'module': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'appear': 0.29; 'message-id:@mail.gmail.com': 0.30; '(most': 0.33; 'guess': 0.33; 'anywhere': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'first': 0.61; 'column.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=YfvnZQzPh5MC+6lI5UekNtHUEAgQ0w66UMyLap5L2jA=; b=w6mAvhTC4iIlz/Dume+rwC4uTKL+mfbMtVKKDxiH4ujvifInpLmySFbCSzef5gk7YT +SgP3GOFmQjFcBOXqXjiEyv+sAL/OoNZT7haD+9JViABFKBzHw7Y5/YbFvrFDS5am0N0 ubnQlKSX22T6ydKdHYXqau2qKl5UOAGrWJVm9fluoWmeaf1EKL9CFumLV9bIetHRmL8Y 21tyCyEeNxzFkwXtoC+5/N8AFLNDq4iTKSz0jirDeCl3Q2xPq/7iyDtqVbnKdYsPiE3X SeQcWcX1AbpMP3U9ht1EnIiPk7tSoeCO1FQJxqb/jmD3pwUw+vkLO44Csk5APJMHG0VA gscw== MIME-Version: 1.0 X-Received: by 10.49.25.112 with SMTP id b16mr34623165qeg.21.1367347355520; Tue, 30 Apr 2013 11:42:35 -0700 (PDT) In-Reply-To: References: <59afdc2b-ab76-40b6-8f63-4a562e288029@googlegroups.com> Date: Tue, 30 Apr 2013 19:42:35 +0100 Subject: Re: how to compare two fields in python From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: upendra kumar Devisetty Content-Type: multipart/alternative; boundary=047d7b6da4c8694a6c04db985d74 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367347358 news.xs4all.nl 15873 [2001:888:2000:d::a6]:38441 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44566 --047d7b6da4c8694a6c04db985d74 Content-Type: text/plain; charset=ISO-8859-1 > The data was sorted and so duplicates will not appear anywhere in the dataframe. > I guess that's it. Use the standard csv module and itertools.groupby. Groupby will produce a list of grouped objects. So you can group by the first column by supplying a key function which just returns the first column. Check this out for an example: http://stackoverflow.com/questions/773/how-do-i-use-pythons-itertools-groupby(most upvoted answer) --047d7b6da4c8694a6c04db985d74 Content-Type: text/html; charset=ISO-8859-1

> The data was sorted and so duplicates will not appear anywhere in the dataframe.
>

I guess that's it. Use the standard csv module and itertools.groupby. Groupby will produce a list of grouped objects. So you can group by the first column by supplying a key function which just returns the first column.

Check this out for an example: http://stackoverflow.com/questions/773/how-do-i-use-pythons-itertools-groupby (most upvoted answer)

--047d7b6da4c8694a6c04db985d74--