You're viewing documentation for outdated of DataMatrix.
Click here to view the up-to-date documentation.
DataMatrix
DataMatrix is an intuitive Python library for working with column-based and continuous data.
Features
- An intuitive syntax that makes your code easy to read.
- Requires only the Python standard libraries (but you can use
numpyto improve performance). - Mix two-dimensional (series) and one-dimensional data in a single data structure.
DataMatrixdoes what it does really well, but it cannot do everything that libraries such aspandascan. Therefore, you can convert to and frompandas.DataFrame.
Video 1. Using
datamatrix to play with movie data.
Example
from datamatrix import DataMatrix
# Four philosophers with their names, fields, and genders
dm = DataMatrix(length=4)
dm.name = 'Ibn al-Haytam', 'Hypatia', 'Popper', 'de Beauvoir'
dm.field = 'Optics', 'Mathematics', 'Science', 'Existentialism'
dm.gender = 'M', 'F', 'M', 'F'
print('Philosophers:')
print(dm)
# Select only women existentialists
dm = (dm.gender == 'F') & (dm.field == 'Existentialism')
print('Women Existentialists:')
print(dm)
Output:
Philosophers:
+---+---------------+----------------+--------+
| # | name | field | gender |
+---+---------------+----------------+--------+
| 0 | Ibn al-Haytam | Optics | M |
| 1 | Hypatia | Mathematics | F |
| 2 | Popper | Science | M |
| 3 | de Beauvoir | Existentialism | F |
+---+---------------+----------------+--------+
Women Existentialists:
+---+-------------+----------------+--------+
| # | name | field | gender |
+---+-------------+----------------+--------+
| 3 | de Beauvoir | Existentialism | F |
+---+-------------+----------------+--------+



