If you have come across lists in Python, you will know that a pair of square brackets ([]) is used to index and subset a list. This square bracket operator is also useful in slicing NumPy arrays. The square bracket [] is the basic indexing operator in pandas as well.
Let's create a Series, DataFrame, and panel to understand how the square bracket operator is used in pandas:
# Creating a series with 6 rows and user-defined index
ser = pd.Series(["Numpy", "Pandas", "Sklearn", "Tensorflow", "Scrapy", "Keras"],
index = ["A", "B", "C", "D", "E", "F"])
# Creating a 6X3 dataframe with defined row and column labels
df = pd.DataFrame(np.random.randn(6, 3), columns = ["colA", "colB", "colC"],
index = ["R1", "...