iode.Comments.from_series

Comments.from_series(s: Series)[source]

Copy the pandas Series s into the IODE Comments database. The comment names to copy are deduced from the index of the Series.

Parameters:
s: Series

pandas Series containing the comments to copy into the IODE Comments database.

Notes

The index of the passed Series is sorted in alphabetical order before copying to IODE Comments database.

Examples

>>> from iode import comments
>>> import pandas as pd
>>> comments.clear()
>>> len(comments)
0
>>> # create the pandas Series
>>> names = ["A0", "A1", "B0", "B1", "C0", "C1"]
>>> data = ["A zero", "A one", "B zero", "B one", "C zero", "C one"]
>>> s = pd.Series(data=data, index=names, dtype=str, name="Comments")
>>> # display the pandas series
>>> s
A0     A zero
A1     A one
B0    B zero
B1     B one
C0    C zero
C1     C one
Name: Comments, dtype: object
>>> # load into the IODE Comments database
>>> comments.from_series(s)
>>> len(comments)
6
>>> comments.names
['A0', 'A1', 'B0', 'B1', 'C0', 'C1']
>>> comments["B0"]
'B zero'
>>> comments["C1"]
'C one'