सामान्य शब्द क्रम

Python में Spark SQL परिचय

Mark Plutowski

Data Scientist

ट्रेनिंग

Python में Spark SQL परिचय

प्रिडिक्टिंग

Python में Spark SQL परिचय

अंतिम शब्द की भविष्यवाणी

Python में Spark SQL परिचय

सीक्वेंस

Python में Spark SQL परिचय

सीक्वेंस - आखिरी

Python में Spark SQL परिचय

The quick brown fox

Python में Spark SQL परिचय

वाक्य ब्रैकेट

Python में Spark SQL परिचय

एक और प्रकार का एग्रीगेशन

Python में Spark SQL परिचय

वीडियो

Python में Spark SQL परिचय

श्रेणीबद्ध डेटा

Python में Spark SQL परिचय

श्रेणीबद्ध बनाम क्रमिक

  • Categorical: he, hi, she, that, they
  • Ordinal: 1, 2, 3, 4, 5
Python में Spark SQL परिचय

सीक्वेंस विश्लेषण

Python में Spark SQL परिचय

पहले और बाद के शब्द

Python में Spark SQL परिचय

3-ट्यूपल्स

query3 = """
   SELECT 
   id,
   word AS w1,
   LEAD(word,1) OVER(PARTITION BY part ORDER BY id ) AS w2,
   LEAD(word,2) OVER(PARTITION BY part ORDER BY id ) AS w3
   FROM df
""" 
Python में Spark SQL परिचय

Subquery में window function SQL

query3agg = """
SELECT w1, w2, w3, COUNT(*) as count FROM (
   SELECT 
   word AS w1,
   LEAD(word,1) OVER(PARTITION BY part ORDER BY id ) AS w2,
   LEAD(word,2) OVER(PARTITION BY part ORDER BY id ) AS w3
   FROM df
)
GROUP BY w1, w2, w3 
ORDER BY count DESC
""" 

spark.sql(query3agg).show()
Python में Spark SQL परिचय

Subquery में window function SQL – आउटपुट

+-----+-----+-----+-----+
|   w1|   w2|   w3|count|
+-----+-----+-----+-----+
|  one|   of|  the|   49|
|    i|think| that|   46|
|   it|   is|    a|   46|
|   it|  was|    a|   45|
| that|   it|  was|   38|
|  out|   of|  the|   35|
|.....|.....|.....|.....|
Python में Spark SQL परिचय

सबसे आम 3-ट्यूपल्स

+-----+-----+-----+-----+
|   w1|   w2|   w3|count|
+-----+-----+-----+-----+
|  one|   of|  the|   49|
|    i|think| that|   46|
|   it|   is|    a|   46|
|   it|  was|    a|   45|
| that|   it|  was|   38|
|  out|   of|  the|   35|
| that|    i| have|   35|
|there|  was|    a|   34|
|    i|   do|  not|   34|
| that|   it|   is|   33|
| that|   he|  was|   30|
| that|   he|  had|   30|
| that|    i|  was|   28|
+-----+-----+-----+-----+
Python में Spark SQL परिचय

एग्रीगेशन का एक और प्रकार

query3agg = """
SELECT w1, w2, w3, length(w1)+length(w2)+length(w3) as length FROM (
   SELECT 
   word AS w1,
   LEAD(word,1) OVER(PARTITION BY part ORDER BY id ) AS w2,
   LEAD(word,2) OVER(PARTITION BY part ORDER BY id ) AS w3
   FROM df
   WHERE part <> 0 and part <> 13
)
GROUP BY w1, w2, w3 
ORDER BY length DESC
""" 

spark.sql(query3agg).show(truncate=False)
Python में Spark SQL परिचय

एग्रीगेशन का एक और प्रकार

+-------------------+-------------------+---------------+------+
|                 w1|                 w2|             w3|length|
+-------------------+-------------------+---------------+------+
|comfortable-looking|           building|    two-storied|    38|
|         widespread|comfortable-looking|       building|    37|
|      extraordinary|      circumstances|      connected|    35|
|      simple-minded|      nonconformist|      clergyman|    35|
|       particularly|          malignant|  boot-slitting|    34|
|       unsystematic|        sensational|     literature|    33|
|       oppressively|        respectable|     frock-coat|    33|
|         relentless|        keen-witted|   ready-handed|    33|
|   travelling-cloak|                and|  close-fitting|    32|
|        ruddy-faced|      white-aproned|       landlord|    32|
|  fellow-countryman|            colonel|       lysander|    32|
+-------------------+-------------------+---------------+------+
Python में Spark SQL परिचय

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

Python में Spark SQL परिचय

Preparing Video For Download...