A Python Library Specialized in Data Processing, Pandas
When working with data such as item sales or customer influx over time, it's typically organized in a table format with rows (horizontal) and columns (vertical).
Pandas is one of the most widely used packages in Python for handling tabular data.
With Pandas, you can systematically perform a variety of tasks—from basic operations like loading and saving data to more complex ones like filtering, sorting, and statistical analysis.
Installing Pandas
You can install Pandas using the following command. However, in the practice environment, Pandas is already installed, so no additional installation is needed.
pip install pandas
Two Data Structures of Pandas
The core data structures of Pandas are Series and DataFrame.
1. Series
A Series is a one-dimensional data structure, conceptually similar to a single column in Excel.
Data is arranged sequentially, similar to a Python list (array).
Each piece of data has a unique index (identifier indicating the position of the data), through which the data can be accessed.
import pandas as pd # Create a series data_series = pd.Series([10, 20, 30, 40]) print(data_series) # Output # 0 10 # 1 20 # 2 30 # 3 40 # dtype: int64
2. DataFrame
A DataFrame is a two-dimensional data structure composed of multiple Series.
It contains both rows and columns, and each column can hold a different data type.
This structure is similar to an Excel table (spreadsheet).
import pandas as pd # Create a DataFrame for sales by item data_frame = pd.DataFrame({ 'Item': ['Apple', 'Banana', 'Strawberry', 'Grapes'], 'Sales': [1000, 2000, 1500, 3000] }) print(data_frame) # Output # Item Sales # 0 Apple 1000 # 1 Banana 2000 # 2 Strawberry 1500 # 3 Grapes 3000
In the example above, the DataFrame is created with columns labeled 'Item' and 'Sales'.
For instance, 'Item': ['Apple', 'Banana', 'Strawberry', 'Grapes'] creates a Series resembling an Excel column, which is then combined with other Series to form the DataFrame.
Lessons in this chapter · Essential Python Libraries for AI
- 1. NumPy: Python Library Optimized for Numerical Computation
- 2. Basic Operations and Advanced Features in NumPy
- 3. Multiple Choice Quiz
- 4. Pandas: Python Library for Data Manipulation
- 5. Basic Operations and Advanced Features in Pandas
- 6. Fill-in-the-Blank Quiz
- 7. Visualize Data with Matplotlib
- 8. Graph Types and Applications with Matplotlib
- 9. Multiple Choice Quiz
- 10. Seaborn: A Visualization Library for Python
- 11. Differences Between Seaborn and Matplotlib and How to Use Both
- 12. Fill-in-the-Blank Quiz
- 13. Scikit-Learn: A Beginner-Friendly Machine Learning Library
- 14. Preprocessing Data and Evaluating Models with Scikit-Learn
- 15. Multiple Choice Quiz
- 16. NLTK: Python Library for Natural Language Processing
- 17. Advanced NLP Techniques with NLTK
- 18. Fill-in-the-Blank Quiz
- 19. OpenCV: Python Library for Computer Vision
- 20. Advanced Image Processing Techniques with OpenCV
- 21. Multiple Choice Quiz
Which word fits best in the blank?
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help