The Pandas Series data structure is a one-dimensional, heterogeneous array with labels, We can create a Pandas Series data structure as follows:
- Using a Python dict
- Using a NumPy array
- Using a single scalar value
When creating a Series, we can hand the constructor a list of axis labels, which is commonly referred to as the index. The index is an optional parameter. By default, if we use a NumPy array as the input data, Pandas will index values by auto incrementing the index commencing from 0. If the data handed to the constructor is a Python dict, the sorted dict keys will become the index. In the case of a scalar value as the input data, we are required to supply the index. For each new value in the index, the scalar input value will be reiterated. The Pandas Series and DataFrame interfaces have features and behaviors borrowed from NumPy arrays and Python dictionaries, such as slicing, a lookup function that uses a key, and vectorized operations. Performing a lookup on a DataFrame column returns a Series. We will demonstrate this and other features of Series by going back to the previous section and loading the CSV file again:
댓글 없음:
댓글 쓰기