Introduction to pandas - pinky884/com.n.learn.samples GitHub Wiki
Introduction:
2 Main datastructures of pandas that are most commonly used
- Series
- DataFrame
Series:
A series is like a 1-dimensional array of objects containing a sequence of values and an associated array of data labels, called its index.
Series is like a python array object which will have an index attribute. The values present in series can be printed using .values Index of series can be printed using .index
Diff between regular python array and pandas series:
Pandas Series can be created with a custom index and can be used to access elements using that custom index.
Ex: series_obj = pd.Series([2,-5,3,9],index=['a','b','c','d] print(series_obj['b'])
The above command prints -5
Another way to think about a Series is as a fixed-length, ordered dict, as it is a mapping of index values to data values.
dict_obj = {"name":"peter","age":35,"country":"US"} \n s_ex3 = pd.Series(dict_obj)
The above statement would print s_ex3["name"] as peter, so on and so forth