本文主要是介绍5、不一致的数据录入,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
有效地修复数据中的拼写错误。
“Inconsistent Data Entry”(不一致的数据录入)是指在进行数据录入时,由于各种原因(如字母大小写不一致、多余的空格、输入错误或表达问题等)导致输入的数据与实际数据不一致的情况。
例如,输入的数据可能本来是一个东西,但是由于字母大小不一致,或者多个空格,或者由于输入问题,或者表达问题,导致一个单词有相似的表达方法,致统计出来的数据是多个。
本节课数据集下载链接:「pakistan_intellectual_capital.csv」https://pan.quark.cn/s/72bb45289cdc
在这个笔记本中,我们将学习如何清理不一致的文本条目。
让我们开始吧!
文章目录
- 1、设置我们的环境
- 2、进行一些初步的文本预处理
- 3、使用模糊匹配来纠正不一致的数据输入
1、设置我们的环境
我们需要做的第一件事是加载我们将要使用的库和数据集。
In [1]:
# 我们将使用的模块
import pandas as pd
import numpy as np# 有用的模块
import fuzzywuzzy
from fuzzywuzzy import process
import charset_normalizer# 读取我们所有的数据
professors = pd.read_csv("../input/pakistan-intellectual-capital/pakistan_intellectual_capital.csv")# 设置种子以保证可重复性
np.random.seed(0)
2、进行一些初步的文本预处理
我们将首先快速查看数据的前几行。
In [2]:
professors.head()
Out[2]:
Unnamed: 0 | S# | Teacher Name | University Currently Teaching | Department | Province University Located | Designation | Terminal Degree | Graduated from | Country | Year | Area of Specialization/Research Interests | Other Information | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2 | 3 | Dr. Abdul Basit | University of Balochistan | Computer Science & IT | Balochistan | Assistant Professor | PhD | Asian Institute of Technology | Thailand | NaN | Software Engineering & DBMS | NaN |
1 | 4 | 5 | Dr. Waheed Noor | University of Balochistan | Computer Science & IT | Balochistan | Assistant Professor | PhD | Asian Institute of Technology | Thailand | NaN | DBMS | NaN |
2 | 5 | 6 | Dr. Junaid Baber | University of Balochistan | Computer Science & IT | Balochistan | Assistant Professor | PhD | Asian Institute of Technology | Thailand | NaN | Information processing, Multimedia mining | NaN |
3 | 6 | 7 | Dr. Maheen Bakhtyar | University of Balochistan | Computer Science & IT | Balochistan | Assistant Professor | PhD | Asian Institute of Technology | Thailand | NaN | NLP, Information Retrieval, Question Answering… | NaN |
4 | 24 | 25 | Samina Azim | Sardar Bahadur Khan Women’s University | Computer Science | Balochistan | Lecturer | BS | Balochistan University of Information Technolo… | Pakistan | 2005.0 | VLSI Electronics DLD Database | NaN |
假设我们对清理 “Country” 列感兴趣,以确保其中没有数据输入的不一致性。当然,我们可以逐行检查,并在发现不一致性时手动纠正。但是,有一种更有效的方法!
In [3]:
# 获取 'Country' 列中所有的唯一值
countries = professors[
这篇关于5、不一致的数据录入的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!