Home Backend Development Python Tutorial pandas implements deduplication of duplicate tables and re-converts them into tables

pandas implements deduplication of duplicate tables and re-converts them into tables

Apr 18, 2018 pm 03:47 PM
pandas sheet

Below I will share with you a pandas method to remove duplicate tables and convert them into tables again. It has a good reference value and I hope it will be helpful to everyone. Let’s take a look together

When processing data in python, DataFrame and set are often used.

train=pd.read_csv('XXX.csv')#读取文件 
train=train['item_id']#选择要去重的列 
train=set(train)#去重 
data=pd.DataFrame(list(train),columns=['item_id'])#因为set是无序的,必须要经过list处理后才能成为DataFrame 
data.to_csv('xxx.csv',index=False)#保存表格
Copy after login

Remember to import pandas~

The above is the detailed content of pandas implements deduplication of duplicate tables and re-converts them into tables. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Steps to adjust the format of pictures inserted in PPT tables Steps to adjust the format of pictures inserted in PPT tables Mar 26, 2024 pm 04:16 PM

Steps to adjust the format of pictures inserted in PPT tables

How to make a table for sales forecast How to make a table for sales forecast Mar 20, 2024 pm 03:06 PM

How to make a table for sales forecast

Solving common pandas installation problems: interpretation and solutions to installation errors Solving common pandas installation problems: interpretation and solutions to installation errors Feb 19, 2024 am 09:19 AM

Solving common pandas installation problems: interpretation and solutions to installation errors

How to set WPS value to automatically change color according to conditions_Steps to set WPS table value to automatically change color according to condition How to set WPS value to automatically change color according to conditions_Steps to set WPS table value to automatically change color according to condition Mar 27, 2024 pm 07:30 PM

How to set WPS value to automatically change color according to conditions_Steps to set WPS table value to automatically change color according to condition

How to read txt file correctly using pandas How to read txt file correctly using pandas Jan 19, 2024 am 08:39 AM

How to read txt file correctly using pandas

Practical tips for reading txt files using pandas Practical tips for reading txt files using pandas Jan 19, 2024 am 09:49 AM

Practical tips for reading txt files using pandas

Revealing the efficient data deduplication method in Pandas: Tips for quickly removing duplicate data Revealing the efficient data deduplication method in Pandas: Tips for quickly removing duplicate data Jan 24, 2024 am 08:12 AM

Revealing the efficient data deduplication method in Pandas: Tips for quickly removing duplicate data

How to insert automatic numbering or serial numbers into Word tables How to insert automatic numbering or serial numbers into Word tables Mar 20, 2024 am 09:30 AM

How to insert automatic numbering or serial numbers into Word tables

See all articles