Original article was published on Artificial Intelligence on Medium
PYTHON Pandas Series
The series is a one-dimensional tagged array that can hold any type of data (integer, string, float, python objects, etc.). Axis labels are collectively called directories.
A pandas Series can be created using the following builder:
pandas.Series( data, index, dtype, copy)
The founder’s parameters are as follows: data: data takes various forms such as ndarray, list, constant
- Index: Index values must be unique and hashable, with the same length as the data.
- dtype: for the dtype data type. If not, the data type will be removed.
- copy: copies the data. the default value is false.
It can be created using several inputs, such as a series:
- Scalar value and constant
Creating an Empty Series
A basic array that can be created is an empty series.
Series(, dtype: float64)
Creating a Series with ndarray
If the data is a ndarray, the passed directory must be of the same length. By default, the index takes the range where n is the array length, rather than the index of the same length. That is: (n) [0,1,2,3 …. Range (len (series)) — 1].
We passed the index values here. Now you can see the output customized index values.
Creating Series with Dict
A dict can be passed as input, and if the index is not specified, dictionary keys are imported in a sequential order to create the index. If the index is passed, the values in the data corresponding to the labels in the index are pulled out.
Creating a Series with Scalar
If the data is a scalar value, a directory must be provided. The value is repeated to match the index length.