Today I would like to pandas in the row to re-operation, looking for a long time, only to find a dozen related functions
Let's look at a small example.
<span style= "FONT-SIZE:18PX;" >from Pandas import Series, Dataframedata = DataFrame ({' K ': [1, 1, 2, 2]}) Print dataisduplicated = data.duplicated () pri NT Isduplicatedprint Type (isduplicated) data = Data.drop_duplicates () print data</span>
The duplicated method of Dataframe returns a Boolean series that indicates whether rows are repeated for each row.
Instead of the Drop_duplicates method, it is used to return a dataframe that removes duplicate rows
Both methods determine all columns, and you can specify a partial column to repeat the sentence.
For example, to remove a column with the name K2,
Data.drop_duplicates ([' K2 '])
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python pandas dataframe de-weight function