PySpark के साथ डेटा क्लीनिंग
Mike Metzger
Data Engineering Consultant
डेटा क्लीनिंग: डेटा प्रोसेसिंग पाइपलाइनों में उपयोग के लिए कच्चे डेटा को तैयार करना.
डेटा क्लीनिंग में संभावित कार्य:
आम डेटा सिस्टम की समस्याएँ:
Spark के फायदे:
कच्चा डेटा:
| name | age (years) | city |
|---|---|---|
| Smith, John | 37 | Dallas |
| Wilson, A. | 59 | Chicago |
| null | 215 |
क्लीन किया हुआ डेटा:
| last name | first name | age (months) | state |
|---|---|---|---|
| Smith | John | 444 | TX |
| Wilson | A. | 708 | IL |
स्कीमा इम्पोर्ट करें
import pyspark.sql.types
peopleSchema = StructType([
# Define the name field
StructField('name', StringType(), True),
# Add the age field
StructField('age', IntegerType(), True),
# Add the city field
StructField('city', StringType(), True)
])
डेटा वाला CSV फ़ाइल पढ़ें
people_df = spark.read.format('csv').load(name='rawdata.csv', schema=peopleSchema)
PySpark के साथ डेटा क्लीनिंग