An intuitive, Pythonic way to work with tabular data

# Python DataMatrix

An intuitive, Pythonic way to work with tabular data.

Sebastiaan Mathôt
https:/datamatrix.cogsci.nl The `datamatrix` package provides a high-level, intuitive way to work with tabular data, that is, datasets that consist of named columns and numbered rows.

The main advantage of `datamatrix` over similar libraries is the clean, Pythonic syntax, which makes your code easy to read and understand.

`datamatrix` is also one of the core libraries of OpenSesame, a graphical experiment builder for the social sciences, and Rapunzel, a modern code editor for numerical computing with Python and R.

## Ultra-short cheat sheet

```from datamatrix import DataMatrix
# Create a new DataMatrix
dm = DataMatrix(length=5)
# The first two rows
print(dm[:2])
# Create a new column and initialize it with the Fibonacci series
dm.fibonacci = 0, 1, 1, 2, 3
# Remove 0 and 3 with a simple selection
dm = (dm.fibonacci > 0) & (dm.fibonacci < 3)
# Select 1, 1, and 2 by matching any of the values in a set
dm = dm.fibonacci == {1, 2}
# Select all odd numbers with a lambda expression
dm = dm.fibonacci == (lambda x: x % 2)
# Change all 1s to -1
dm.fibonacci[dm.fibonacci == 1] = -1
# The first two cells from the fibonacci column
print(dm.fibonacci[:2])
# Column mean
print('Mean: %s' % dm.fibonacci.mean)
# Multiply all fibonacci cells by 2
dm.fibonacci_times_two = dm.fibonacci * 2
# Loop through all rows
for row in dm:
print(row.fibonacci) # get the fibonacci cell from the row
# Loop through all columns
for colname, col in dm.columns:
for cell in col: # Loop through all cells in the column
print(cell) # do something with the cell
# Or just see which columns exist
print(dm.column_names)
```

## Dependencies

• Python >= 3.7

Optional:

• `numpy` and `scipy` for using the `FloatColumn`, `IntColumn`, and `SeriesColumn` objects
• `prettytable` for creating a text representation of a DataMatrix (e.g. to print it out)
• `openpyxl` for reading and writing `.xlsx` files
• `fastnumbers` for improved performance

## Installation

### PyPi

``````pip install python-datamatrix
``````

### Anaconda

``````conda install python-datamatrix -c cogsci -c conda-forge
``````

### Ubuntu

``````sudo add-apt-repository ppa:smathot/cogscinl
sudo apt-get update
sudo apt install python3-datamatrix
``````

## Documentation

`python-datamatrix` is licensed under the GNU General Public License v3.

## Project details

This version 0.12.0 0.11.1 0.11.0 0.10.19 0.10.18 0.10.17 0.10.15 0.10.14 0.10.13 0.10.12 0.10.11 0.10.10 0.10.8 0.10.7 0.10.6 0.10.5 0.10.4 0.10.3 0.10.2 0.10.1 0.10.0 0.9.14 0.9.13 0.9.12 0.9.11 0.9.10 0.9.9 0.9.8 0.9.7 0.9.6 0.9.5 0.9.4 0.9.3 0.9.2 0.9.1 0.8.3 0.8.2 0.8.1 0.8.0 0.7.1 0.7.0 0.6.3 0.6.2 0.6.1 0.6.0 0.5.0 0.4.15 0.4.14 0.4.13 0.4.12 0.4.11 0.4.10 0.4.9 0.4.8 0.4.7 0.4.6 0.4.4 0.4.3 0.4.2 0.4.1 0.3.8 0.3.7 0.3.6 0.3.5 0.3.4 0.3.3 0.3.2 0.3.1 0.3.0 0.2.0 0.1.2 0.1.1 0.1.0