डेटा टाइप constraints

Python में डेटा क्लीनिंग

Adel Nehme

VP of AI Curriculum, DataCamp

कोर्स रूपरेखा

गंदा डेटा

Python में डेटा क्लीनिंग

कोर्स रूपरेखा

साइड इफेक्ट्स

Python में डेटा क्लीनिंग

कोर्स रूपरेखा

साफ डेटा

Python में डेटा क्लीनिंग

कोर्स रूपरेखा

साफ डेटा

अध्याय 1 - आम डेटा समस्याएँ

Python में डेटा क्लीनिंग

हमें डेटा क्यों साफ करना चाहिए?

डेटा साइंस वर्कफ़्लो

Python में डेटा क्लीनिंग

हमें डेटा क्यों साफ करना चाहिए?

डेटा साइंस वर्कफ़्लो

Python में डेटा क्लीनिंग

हमें डेटा क्यों साफ करना चाहिए?

                                                                                   Garbage in Garbage out

Python में डेटा क्लीनिंग

डेटा टाइप constraints

डेटा टाइप उदाहरण
टेक्स्ट डेटा First name, last name, address ...
इंटेजर्स # Subscribers, # products sold ...
डेसिमल्स Temperature, $ exchange rates ...
बाइनरी Is married, new customer, yes/no, ...
डेट्स Order dates, ship dates ...
कैटेगरीज़ Marriage status, gender ...
Python data type
str
int
float
bool
datetime
category
Python में डेटा क्लीनिंग

Strings से integers

# Import CSV file and output header
sales = pd.read_csv('sales.csv')
sales.head(2)
   SalesOrderID    Revenue    Quantity
0         43659     23153$          12
1         43660      1457$           2
# Get data types of columns
sales.dtypes
SalesOrderID    int64
Revenue         object
Quantity        int64
dtype: object
Python में डेटा क्लीनिंग

String से integers

# Get DataFrame information
sales.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 31465 entries, 0 to 31464
Data columns (total 3 columns):
SalesOrderID     31465 non-null int64
Revenue          31465 non-null object
Quantity         31465 non-null int64
dtypes: int64(2), object(1)
memory usage: 737.5+ KB
Python में डेटा क्लीनिंग

String से integers

# Print sum of all Revenue column
sales['Revenue'].sum()
'23153$1457$36865$32474$472$27510$16158$5694$6876$40487$807$6893$9153$6895$4216..
# Remove $ from Revenue column
sales['Revenue'] = sales['Revenue'].str.strip('$')
sales['Revenue'] = sales['Revenue'].astype('int')
# Verify that Revenue is now an integer
assert sales['Revenue'].dtype == 'int'
Python में डेटा क्लीनिंग

assert स्टेटमेंट

# This will pass
assert 1+1 == 2
# This will not pass
assert 1+1 == 3
AssertionError                            Traceback (most recent call last)
         assert 1+1 == 3
AssertionError:
Python में डेटा क्लीनिंग

न्यूमेरिक या कैटेगोरिकल?

...   marriage_status    ...
...                 3    ...
...                 1    ...
...                 2    ...

0 = Never married       1 = Married       2 = Separated       3 = Divorced

df['marriage_status'].describe()
       marriage_status
...
mean              1.4
std               0.20
min               0.00
50%               1.8 ...
Python में डेटा क्लीनिंग

न्यूमेरिक या कैटेगोरिकल?

# Convert to categorical
df["marriage_status"] = df["marriage_status"].astype('category')

df.describe()
        marriage_status
count                 241
unique                4
top                   1
freq                  120
Python में डेटा क्लीनिंग

अभ्यास करते हैं!

Python में डेटा क्लीनिंग

Preparing Video For Download...