Pandas adds some great data management functionality to Python. Pandas allows you to create series and dataframes.
Series
Think of a series as combination of a list and a dictionary.
To use pandas, first we need to import it.
To create as series with pandas, use the following syntax
- variable = Series([item1, item2, … item_n])
** note Series is capitalized. This method is case sensitive
pandas Series can contain numbers or strings. You call elements in a Series like you do a list. variable[index]
You can create you own index in a Series as well, making it function a lot like a dictionary.
Notice with the syntax leg[leg==4] I am able to filter by items equal to 4
If you have an existing dictionary, you can convert it into a pandas Series
You can call the index and values of a Series using the following methods:
If you enjoyed this lesson, click LIKE below, or even better, leave me a COMMENT.
Last Lesson: Numpy Part II
Next Lesson: Pandas DataFrames
Return to: Python for Data Science Course
Follow this link for more Python content: Python