ztree2python
ztree2python
ztree2python imports a data file created by z-Tree (Fischbacher, 2007) into python as pandas dataframes. This function inputs the "filename" of a z-Tree data file, and it returns a dictionary, which contains the dataframes of the tables. The keys are the names of all tables, "globals", "subjects", and so on. The value associated with each key is a pandas dataframe for the table.
Installation
Use the package manager pip to install.
pip install ztree2python
Alternatively, simply put ztree2python.py and a z-Tree data file (e.g., 221215_1236.xls) in the current directory or the working directory.
For example, run the following commands.
from ztree2python import ztree2python as ztree2python
# input the file name, and it returns a dictionary.
tables = ztree2python('221215_1449.xls')
The function returns a dictionary, name "tables" in this example. Each table is stored as a dataframe in the "tables". Get the data of a table as follows:
# Extract a table by name, for example, the "subjects" table.
my_table = tables['subjects']
my_table.head()
For further information, please visit the github page.
License
MIT. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
Reference
Fischbacher, U. (2007). z-Tree: Zurich toolbox for ready-made economic experiments. Experimental Economics, 10(2), 171-178. https://doi.org/10.1007/s10683-006-9159-4.
Takeuchi, K. (2023). ztree2stata: A data converter for z-Tree and Stata users. Journal of Economic Science Association, 9, 136-146.
https://link.springer.com/article/10.1007/s40881-023-00130-w (To access the PDF of the paper, click here.)
Takeuchi, Kan. (2022). ztree2python.py, http://github.com/takekan/ztree2python.