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).
  • 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 as pandas can. Therefore, you can convert to and from pandas.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:
+---+---------------+----------------+--------+
| # |      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    |
+---+-------------+----------------+--------+