import … as …
`import module as alias` loads a module and gives it a shorter or clearer name in your code.
Used in 16 lessons of the course, from 00.05.
A plain import creates a name equal to the module's name. With as, you pick that name yourself.
import pandas as pd reads: "import pandas and call it pd". From then on you write pd.something, and the name pandas does not exist in your code.
Why do it? Two reasons. First, to type less with long module names. Second, because the community has conventional aliases (pd for pandas, np for numpy) and everyone recognizes them when reading.
The alias is just a name in your file. The module is the same object; nothing is copied or changed.
The course shows it from lesson 00.05 with import pandas as pd. Use the usual alias rather than inventing your own.
import math as m
print(m.sqrt(9))
Reach for it when: a module has a long name or when there is a conventional alias everyone uses, like `pd` for pandas.
Examples
Common mistake
import math as m print(math.sqrt(9))
Why: With `as`, the name `math` is not created. Only `m` exists.
How to write it: Use the alias: m.sqrt(9). Or drop the as if you prefer math.
