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
numpy
to improve performance). - Great support for functional programming.
- Mix two-dimensional (series) and one-dimensional data in a single data structure.
DataMatrix
does what it does really well, but it cannot do everything that libraries such aspandas
can. Therefore, you can convert to and frompandas.DataFrame
.
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:
+---+----------------+--------+---------------+
| # | field | gender | name |
+---+----------------+--------+---------------+
| 0 | Optics | M | Ibn al-Haytam |
| 1 | Mathematics | F | Hypatia |
| 2 | Science | M | Popper |
| 3 | Existentialism | F | de Beauvoir |
+---+----------------+--------+---------------+
Women Existentialists:
+---+----------------+--------+-------------+
| # | field | gender | name |
+---+----------------+--------+-------------+
| 3 | Existentialism | F | de Beauvoir |
+---+----------------+--------+-------------+