pandas.Series of pymatgen
Structure Objects, I was wondering if there’s a specific way to return the related compositions out of Structures, eventually in a separated ‘formula’ column of the dataframe.
Hi @Federico_Ottomano , the best way is to retrieve the
composition.reduced_formula attribute of the
Strucutre object. If your structures are in a pandas
DataFrame, you could write a simple function to do this an then use pandas
df["new_column"] = df.apply(get_comp, axis=1)
This assumes your
DataFrame is called
df and the
Structure are stored in a column named “structure”. (there may be small mistakes in the above; I suggest cross-checking the syntax in the pandas docs)
Hope this helps.
Many thanks! It actually was that simple…^^