October 2019
Beginner to intermediate
674 pages
16h 43m
English
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 indexser = pd.Series(["Numpy", "Pandas", "Sklearn", "Tensorflow", "Scrapy", "Keras"], index = ["A", "B", "C", "D", "E", "F"])# Creating a 6X3 dataframe with defined row and column labelsdf = pd.DataFrame(np.random.randn(6, 3), columns = ["colA", "colB", "colC"], index = ["R1", "R2", "R3", "R4", "R5", "R6"]) ...
Read now
Unlock full access