Python pandas dataframe de-weight function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.