Path: blob/main/resources/week-2/QueryingSeries_ed.ipynb
3230 views
In this lecture, we'll talk about one of the primary data types of the Pandas library, the Series. You'll learn about the structure of the Series, how to query and merge Series objects together, and the importance of thinking about parallelization when engaging in data science programming.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-8-bd1f5b262fbc> in <module>
2 # an index of zero, instead we have to call iloc explicitly if we want the first item.
3
----> 4 s[0]
/opt/conda/lib/python3.7/site-packages/pandas/core/series.py in __getitem__(self, key)
1062 key = com.apply_if_callable(key, self)
1063 try:
-> 1064 result = self.index.get_value(self, key)
1065
1066 if not is_scalar(result):
/opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_value(self, series, key)
4721 k = self._convert_scalar_indexer(k, kind="getitem")
4722 try:
-> 4723 return self._engine.get_value(s, k, tz=getattr(series.dtype, "tz", None))
4724 except KeyError as e1:
4725 if len(self) > 0 and (self.holds_integer() or self.is_boolean()):
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
KeyError: 0
In this lecture, we focused on one of the primary data types of the Pandas library, the Series. You learned how to query the Series, with .loc and .iloc, that the Series is an indexed data structure, how to merge two Series objects together with append(), and the importance of vectorization.
There are many more methods associated with the Series object that we haven't talked about. But with these basics down, we'll move on to talking about the Panda's two-dimensional data structure, the DataFrame. The DataFrame is very similar to the series object, but includes multiple columns of data, and is the structure that you'll spend the majority of your time working with when cleaning and aggregating data.