Problem in creating JarvisCFID descriptors

I loaded my dataset in a dataframe called ‘df’ and then used the following commands to create JarvisCFID descriptors -

from matminer.featurizers.structure import JarvisCFID
jv = JarvisCFID()
df = jv.featurize_dataframe(df, ‘structure’)

But I am getting an error saying -
AttributeError: ‘str’ object has no attribute ‘cart_coords’

Can someone help me to resolve this error?

It seems like your structure objects are actually strings. If you do this:

s0 = df["structure"].iloc[0]
print(type(s0))
print(s0)

Does the print(type(s0)) say str?

So to featurize them you’ll need to convert them to pymatgen structures. To advise you on how to convert them, you should post an example of a structure string in your df

Note this code seems to work for me, as a test:

from matminer.datasets import load_dataset
from matminer.featurizers.structure import JarvisCFID

df = load_dataset("matbench_dielectric").iloc[:10]
df = jf.featurize_dataframe(df, "structure")

Thank you for replying to my query. Yes, my structure objects are strings. Could you please tell me the procedure for converting strings to pymatgen structures? An example of a structure string present in my dataset is -
Full Formula (Ac1 Cr1 O3)
Reduced Formula: AcCrO3
abc : 3.989313 3.989313 3.989313
angles: 90.000000 90.000000 90.000000
Sites (5)

SP a b c magmom


0 Ac 0 0 0 0.014
1 Cr 0.5 0.5 0.5 2.852
2 O 0.5 0.5 0 0.01
3 O 0.5 0 0.5 0.01
4 O 0 0.5 0.5 0.01

hmm it seems like you have saved the python print output of the structure, which might be a bit of a pain to reverse engineer.

As a first step, I would try re-downloading the dataset from wherever you got it from but saving the structures as pmg structure objects rather than strings (i.e., I am guessing there is some code you ran which accidentally converted these structures to strings and put them in the dataframe)

FYI Matminer has a function in matminer.utils.io called store_dataframe_as_json which can write (and load_dataframe_from_json which can read) dataframe files containing pmg objects to/from disk.