Importing Libraries with Aliases in Python

In Python, it's common practice to import libraries using aliases β€” short names that make code easier to write and read. This is especially common in data science and analytics.

Example

import pandas as pd
import seaborn as sns

These aliases are not mandatory but are standard practice in the Python community. It gives the following advantages:

Common Aliases

Library Alias
pandas pd
numpy np
matplotlib.pyplot plt
seaborn sns

Without an Alias

You can still import the full library:

import seaborn
df = seaborn.load_dataset("tips")

But this is verbose and non-idiomatic for most data analysis work.