From 8285c15394e09d7fa68f5d73abb8e6e1035406b9 Mon Sep 17 00:00:00 2001 From: "Peter J. Molfese" Date: Thu, 20 Apr 2023 15:58:39 -0400 Subject: [PATCH] add pandas version check >= 1.5.2 and mod behavior (#938) * add version check and mod behavior if pandas >= 1.5.2 to prevent error in writing csv * formatting * adding P. Molfese --------- Co-authored-by: Molfese --- .zenodo.json | 5 +++++ tedana/io.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.zenodo.json b/.zenodo.json index 5c3aacd77..693dde392 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -78,6 +78,11 @@ "affiliation": "Basque Center on Cognition, Brain and Language", "orcid": "0000-0002-2553-3327" }, + { + "name": "Molfese, Peter", + "affiliation": "National Institutes of Mental Health, CMN", + "orcid": "0000-0002-3045-9408" + }, { "name": "Salo, Taylor", "affiliation": "Florida International University", diff --git a/tedana/io.py b/tedana/io.py index 112e4401d..d5a82892b 100644 --- a/tedana/io.py +++ b/tedana/io.py @@ -265,7 +265,14 @@ def save_tsv(self, data, name): data_type = type(data) if not isinstance(data, pd.DataFrame): raise TypeError(f"data must be pd.Data, not type {data_type}.") - data.to_csv(name, sep="\t", line_terminator="\n", na_rep="n/a", index=False) + if versiontuple(pd.__version__) >= versiontuple("1.5.2"): + data.to_csv(name, sep="\t", lineterminator="\n", na_rep="n/a", index=False) + else: + data.to_csv(name, sep="\t", line_terminator="\n", na_rep="n/a", index=False) + + +def versiontuple(v): + return tuple(map(int, (v.split(".")))) def get_fields(name):