Python pandas dataframe to redo functions

Source: Internet
Author: User

Today, I want to pandas in the row of the operation, looking for a long time to find the relevant functions

First look at a small example


From pandas import Series, dataframe

data = Dataframe ({' K ': [1, 1, 2, 2]})

print data

isduplicated = DATA.DUPL icated ()

print isduplicated
print type (isduplicated)

data = Data.drop_duplicates ()
print data


The results of the execution are:


   K
0  1
1  1
2  2 3 2
0    False
1     True
2    False
3     True
   K
0  1
2  2


The Dataframe duplicated method returns a Boolean series that indicates whether rows are repeated for each row.


The Drop_duplicates method, which is used to return a dataframe that removes duplicate rows


These two methods will judge all the columns, and you can specify a partial column to repeat the paragraph.

For example, you want to go heavy on a column named K2,

Data.drop_duplicates ([' K2 '])



Related Article

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.