Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading