Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- line color
- MySQL
- For loops
- train/test
- Text Analytics
- PANDAS
- iterates
- PROJECT
- line width
- matplotlib.pyplot
- data distribution
- machine learning
- matplotlib
- AS
- self parameter
- Python
- __init__
- Else
- error
- polynomial regression
- start exercise
- pie charts
- SQL
- break
- Github
- Default X points
- continue
- Text mining
- variables
- multiple lines
Archives
- Today
- Total
Data Science Explorer
Pandas: Fixing Wrong Data 본문
반응형
Wrong data is just a wrong data like if someone registered 90 instead of 9.0.
- Replacing Values
One way to fix wrong values is to replace them with something else.
Example
Set "Duration" = 80 in row 2.
df.loc[2, 'Duration'] = 80
- Removing Rows
Another way of handling wrong data is to remove the rows that contains wrong data.
Example
Delete rows where "Duration" is higher than 130.
for x in df.index:
if df.loc[x, "Duration"] > 130:
df.drop(x, inplace = True)
Exercise
Loop through all values in the "Duration" column. If the value is higher than 120, set it to 120.
for x in df.index:
if df.loc[x, "Duration"] > 120:
df.loc [x, "Duration"] = 120
'Python' 카테고리의 다른 글
Matplotlib (0) | 2023.11.04 |
---|---|
Pandas: Removing Duplicates (0) | 2023.10.30 |
Pandas: Cleaning Data of Wrong Format (0) | 2023.10.29 |
Pandas: Cleaning Empty Cells (2) | 2023.10.29 |
Pandas Read CSV (0) | 2023.10.28 |