June 2020
Intermediate to advanced
382 pages
11h 39m
English
A DataFrame is a data structure used to store tabular data available in Python's pandas package. It is one of the most important data structures for algorithms and is used to process traditional structured data. Let's consider the following table:
| id | name | age | decision |
| 1 | Fares | 32 | True |
| 2 | Elena | 23 | False |
| 3 | Steven | 40 | True |
Now, let's represent this using a DataFrame.
A simple DataFrame can be created by using the following code:
>>> import pandas as pd>>> df = pd.DataFrame([ ... ['1', 'Fares', 32, True], ... ['2', 'Elena', 23, False], ... ['3', 'Steven', 40, True]]) >>> df.columns = ['id', 'name', 'age', 'decision'] >>> df id name age decision 0 1 Fares 32 True 1 2 Elena 23 False 2 3 Steven 40 True
Note that, in the preceding ...