read_nmr() returns a SpinCollection, but there is currently no direct way to convert a loaded object into a pandas/polars DataFrame. Tabular export is only available through spinplots.utils.nmr_df, which requires working from file paths rather than from already-loaded objects.
One could make it easier and more consistent by implementing a to_pandas() to both Spin and SpinCollection.
Example
from spinplots.io import read_nmr
collection = read_nmr([
"data/1D/glycine/pdata/1",
"data/1D/alanine/pdata/1",
], tags=["Glycine", "Alanine"])
df = collection.to_pandas()
df.to_csv("spectra.csv", index=False)
Behaviour
Spin.to_pandas() returns a DataFrame for a single spectrum
SpinCollection.to_pandas() returns a concatenated DataFrame with a tag column
nmr_df() can remain for backward compatibility, but internally both paths could share the same dataframe-building logic
read_nmr()returns aSpinCollection, but there is currently no direct way to convert a loaded object into a pandas/polarsDataFrame. Tabular export is only available throughspinplots.utils.nmr_df, which requires working from file paths rather than from already-loaded objects.One could make it easier and more consistent by implementing a
to_pandas()to bothSpinandSpinCollection.Example
Behaviour
Spin.to_pandas()returns a DataFrame for a single spectrumSpinCollection.to_pandas()returns a concatenated DataFrame with atagcolumnnmr_df()can remain for backward compatibility, but internally both paths could share the same dataframe-building logic