Get properties of several elements

22 views
Skip to first unread message

Houssam Houssam

unread,
Sep 29, 2019, 4:27:04 PM9/29/19
to matminer
Hello everyone,
Am working on a project in which am looking to Get properties of several elements In my example i have to deal with each elements separately My question is how to get many elements calculated together Any advice given would be much appreciated. Thanks


from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
mpdr = MPDataRetrieval()
df = mpdr.get_dataframe(criteria="Ti", properties=['density', 'pretty_formula'])
print(format(df['density'].count()))
print(df.head())
# use working with any problems
But for nelements


from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
mpdr = MPDataRetrieval()
df = mpdr.get_dataframe(criteria=['Ti', 'Mg', 'Li', 'Na']), properties=['density', 'pretty_formula'])
print(format(df['density'].count()))
print(df.head())


SyntaxError

df = mpdr.get_dataframe(criteria=['Ti', 'Mg', 'Li', 'Na']), properties=['density', 'pretty_formula'])

^
SyntaxError: invalid syntax

Houssam Houssam

unread,
Oct 3, 2019, 8:19:11 AM10/3/19
to matminer
Hey
Any answers

Alex Dunn

unread,
Oct 3, 2019, 6:14:47 PM10/3/19
to matminer
Hey Houssam,

The MPDataRetrieval criteria argument takes the same arguments as the  MPRester object criteria from the pymatgen.  See https://pymatgen.org/_modules/pymatgen/ext/matproj.html and go to the MPRester.query method, and check out the documentation for the criteria argument. You can also refer to the materials project API https://materialsproject.org/docs/api

As a quick answer though, I'd imagine your search would work if you do criteria={"elements": {"$in": ["Ti", "Mg", "Li", "Na"]},  "nelements": 1} or just criteria={"elements": ["Ti", "Mg", "Li", "Na"]}. 

Thanks,
Alex
Reply all
Reply to author
Forward
0 new messages