Get properties of several elements

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

Hey
Any answers

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

···

On Sunday, September 29, 2019 at 1:27:04 PM UTC-7, Houssam Houssam wrote:

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