Package: datamatrix
Python DataMatrixAn intuitive, Pythonic way to work with tabular data.Sebastiaan MathôtCopyright 2015-2024https://pydatamatrix.eu/ContentsAboutFeaturesUltra-short cheat sheetDocumentationDependenciesInstallationLicenseAboutDataMatrixis an intuitive Python library for working with column-based, time-series, and multidimensional data. It's a light-weight and easy-to-use alternative topandas.DataMatrixis also one of the core libraries ofOpenSesame, a graphical experiment builder for the social sciences, andRapunzel, a modern code editor for numerical computing with Python and R.FeaturesAn intuitive syntaxthat makes your code easy to readMix tabular data withtime seriesandmultidimensional datain a single data structureSupport forlarge databy intelligent (and automatic) offloading of data to disk when memory is running lowAdvancedmemoization (caching)Requires only the Python standard libraries (but you can usenumpyto improve performance)Compatible with your favorite data-science libraries:seabornandmatplotlibforplottingscipy,statsmodels, andpingouinforstatisticsmnefor analysis of electroencephalographic (EEG) and magnetoencephalographic (MEG) dataConvertto and frompandas.DataFrameLooks pretty inside a Jupyter NotebookUltra-short cheat sheetfromdatamatriximportDataMatrix,io# Read a DataMatrix from filedm=io.readtxt('data.csv')# Create a new DataMatrixdm=DataMatrix(length=5)# The first two rowsprint(dm[:2])# Create a new column and initialize it with the Fibonacci seriesdm.fibonacci=0,1,1,2,3# You can also specify column names as if they are dict keysdm['fibonacci']=0,1,1,2,3# Remove 0 and 3 with a simple selectiondm=(dm.fibonacci>0)&(dm.fibonacci<3)# Get a list of indices that match certain criteriaprint(dm[(dm.fibonacci>0)&(dm.fibonacci<3)])# Select 1, 1, and 2 by matching any of the values in a setdm=dm.fibonacci=={1,2}# Select all odd numbers with a lambda expressiondm=dm.fibonacci==(lambdax:x%2)# Change all 1s to -1dm.fibonacci[dm.fibonacci==1]=-1# The first two cells from the fibonacci columnprint(dm.fibonacci[:2])# Column meanprint(dm.fibonacci[...])# Multiply all fibonacci cells by 2dm.fibonacci_times_two=dm.fibonacci*2# Loop through all rowsforrowindm:print(row.fibonacci)# get the fibonacci cell from the row# Loop through all columnsforcolname,colindm.columns:forcellincol:# Loop through all cells in the columnprint(cell)# do something with the cell# Or just see which columns existprint(dm.column_names)DocumentationThe basic documentation (including function and module references) is hosted onhttps://pydatamatrix.eu/. Additional tutorials can be found in the data-science course onhttps://pythontutorials.eu/.DependenciesDataMatrixrequires only the Python standard library. That is, you can use it without installing any additional Python packages (although the pip and conda packages install some of the optional dependencies by default). Python 3.7 and higher are supported.The following packages are required for extra functionality:numpyandscipyfor using theFloatColumn,IntColumn,SeriesColumn,MultiDimensionalColumnobjectspandasfor conversion to and frompandas.DataFramemnefor conversion to and frommne.Epochsandmne.TFRfastnumbersfor improved performanceprettytablefor creating a text representation of a DataMatrix (e.g. to print it out)openpyxlfor reading and writing.xlsxfilesjson_tricksfor hashing, serialization to and fromjson, and memoization (caching)tomlkitfor reading configuration frompyproject.tomlpsutilfor dynamic loading of large dataInstallationPyPipip install datamatrixHistorical note:The DataMatrix project used to correspond to another package of the same name, which was discontinued in 2010. If you want to install this package, you can do still do so by providing an explicit version (0.9 is the latest version of this package), as shown below. With thanks todennogumi.orgfor handing over this project's entry on PyPi, thus avoiding much unnecessary confusion!# Doesn't install datamatrix but a previous package by the same name!
pip install datamatrix==0.9Anacondaconda install datamatrix -c conda-forgeUbuntusudo add-apt-repository ppa:smathot/cogscinl  # for stable releases
sudo add-apt-repository ppa:smathot/rapunzel  # for development releases
sudo apt-get update
sudo apt install python3-datamatrixLicensepython-datamatrixis licensed under theGNU General Public License
v3.