Python import syntax: I don't recognize this ("It's wrong …")

The documentation for PySpark includes the following in an example:

from pyspark.context import SparkContext
from pyspark.sql.functions 
import *from pyspark.sql.types 
import *from datetime import date, timedelta, datetime

I don’t recognize or understand the syntax of the last two lines. (Specifically: import *from.) Would someone kindly explain it to me, and point out where it is documented?

I know about . and .. in import paths ("relative import paths"), but this syntax is new to me and I can’t find where it is documented or what it is called. I also notice that the third line contains from but no import and I don’t understand that, either.

The web site where I found this is: https://towardsdatascience.com/pyspark-and-sparksql-basics-6cb4bf967e53 at the end of "Step One." Page written January 10, 2020.

(Topic title edited to indicate that we’ve concluded the web page is wrong. A comment below provides the location of the correct code, on GitHub.)

>Solution :

The line breaks in that code are in the wrong place. It should be

import pandas as pd
from pyspark.sql import SparkSession
from pyspark.context import SparkContext
from pyspark.sql.functions import *
from pyspark.sql.types import *
from datetime import date, timedelta, datetime
import time

Leave a Reply