Beispiel #1
0
    Use the .avg() method on the by_month_dest DataFrame to get the average dep_delay in each month for each destination.
    Find the corresponding standard deviation of each average by using the .agg() method with the function F.stddev().

    Take Hint (-30xp)
'''
# Import pyspark.sql.functions as F
import ____ as F

# Group by month and dest
by_month_dest = flights.groupBy(____)

# Average departure delay by month and destination
by_month_dest.____.show()

# Standard deviation
by_month_dest.agg(F.____(_____)).show()
'''
Joining II

In PySpark, joins are performed using the DataFrame method .join(). This method takes three arguments. The first is the second DataFrame that you want to join with the first one. The second argument, on, is the name of the key column(s) as a string. The names of the key column(s) must be the same in each table. The third argument, how, specifies the kind of join to perform. In this course we'll always use the value how="leftouter".

The flights dataset and a new dataset called airports are already in your workspace.
Instructions
100xp
Instructions
100xp

    Examine the airports DataFrame by printing the .show(). Note which key column will let you join airports to the flights table.
    Rename the faa column in airports to dest by re-assigning the result of airports.withColumnRenamed("faa", "dest") to airports.
    Join the airports DataFrame to the flights DataFrame on the dest column by calling the .join() method on flights. Save the result as flights_with_airports.
        The first argument should be the other DataFrame, airports.
# Importa la clase de lenguaje "Spanish" y crea el objeto nlp
from ____ import ____

nlp = ____

# Procesa el texto
doc = ____("Me gustan las panteras negras y los leones.")

# Selecciona el primer token
first_token = doc[____]

# Imprime en pantalla el texto del token
print(first_token.____)
from spacy.lang.de import German

nlp = German()

# Importiere die Klasse Doc
from ____ import ____

# Erwarteter Text: "Was, echt?!"
words = [____, ____, ____, ____, ____]
spaces = [____, ____, ____, ____, ____]

# Erstelle ein Doc mit den Wörtern und Leerzeichen
doc = ____(____, ____=____, ____=____)
print(doc.text)
Beispiel #4
0
# 导入英文语言类并创建nlp对象
from ____ import ____

nlp = ____

# 处理文本
doc = ____("I like tree kangaroos and narwhals.")

# 截取Doc中"tree kangaroos"的部分
tree_kangaroos = ____
print(tree_kangaroos.text)

# 截取Doc中"tree kangaroos and narwhals"的部分(不包括".")
tree_kangaroos_and_narwhals = ____
print(tree_kangaroos_and_narwhals.text)
Beispiel #5
0
from spacy.lang.fr import French

nlp = French()

# Importe la classe Doc
from ____ import ____

# Texte désiré : "spaCy est cool."
words = ["spaCy", "est", "cool", "."]
spaces = [True, True, False, False]

# Crée un Doc à partir des mots et des espaces
doc = ____(____, words=words, spaces=spaces)
print(doc.text)
# 导入中文语言类创建nlp对象
from ____ import ____

nlp = ____

# 处理文本
doc = ____("我喜欢老虎和狮子。")

# 选择第一个词符
first_token = doc[____]

# 打印第一个词符的文本
print(first_token.____)
# Create a datetime object representing the current time
from datetime import datetime
from dateutil.tz import tzlocal
start_time = datetime.now(tzlocal())

# Import the NWBFile class
from ____ import ____

nwbfile = ____(____='A description for this session',
               ____='Mouse10-Day1',
               ____=start_time)
print('Session ID:', nwbfile.____)
Beispiel #8
0
# Import the color module
from ____ import ____

# Import the filters module and sobel function
from skimage.____ import ____

# Make the image grayscale
soaps_image_gray = ____.____(soaps_image)

# Apply edge detection filter
edge_sobel = ____(____)

# Show original and resulting image to compare
show_image(soaps_image, "Original")
show_image(edge_sobel, "Edges with Sobel")
Beispiel #9
0
# Importe la classe de langue "Français" et crée l'objet nlp
from ____ import ____

nlp = ____

# Traite le texte
doc = ____("La forêt est peuplée de loups gris et renards roux.")

# La portion du Doc pour "loups gris"
loups_gris = ____
print(loups_gris.text)

# La portion du Doc pour "loups gris et renards roux" (sans le ".")
loups_gris_et_renards_roux = ____
print(loups_gris_et_renards_roux.text)
# 日本語クラスをインポートし、nlpオブジェクトを作成
from ____ import ____

nlp = ____

# テキストを処理
doc = ____("私はツリーカンガルーとイルカが好きです。")

# 「ツリーカンガルー」のスライスを選択
tree_kangaroos = ____
print(tree_kangaroos.text)

# 「ツリーカンガルーとイルカ」のスライスを選択
tree_kangaroos_and_dolphins = ____
print(tree_kangaroos_and_dolphins.text)
Beispiel #11
0
# Importiere die Klasse German und erstelle das nlp-Objekt
from ____ import ____

nlp = ____

# Verarbeite den Text
doc = ____("Ich mag niedliche Katzen und Faultiere.")

# Ein Abschnitt des Docs für "niedliche Katzen"
niedliche_katzen = ____
print(niedliche_katzen.text)

# Ein Abschnitt des Docs für "niedliche Katzen und Faultiere" (ohne ".")
niedliche_katzen_und_faultiere = ____
print(niedliche_katzen_und_faultiere.text)