Extracting data frame from MP using Matminer's get_dataframe() method

I am trying to query and extract a dataset from the MP database into a data frame for matminer like below, but it is not working:

import pandas as pd
from mp_api.client import MPRester
from matminer.data_retrieval.retrieve_MP import MPDataRetrieval
with MPRester(JOHAN_API_KEY) as mpr:
    criteria = mpr.summary.search(elements=["B"], exclude_elements=["N","Ca","Li","Ca","Mg","Na","K","Rb","Cs","Fr","Be","Sr","Ba","Ra","H","O","P","F","Cl"]     
                                ,fields=["material_id", "formula_pretty", "dos","structure"])

with MPDataRetrieval(api_key=JOHAN_API_KEY) as mpdr:
    df = mpdr.get_dataframe(criteria)

    display(df)
3 Likes

Can you please show the error details?

Hi,

I was able to fix this by just using the pd.DataFrame() method not the MpDataRetrieval() like below.

Full_dataset = pd.DataFrame(criteria)

thanks for your help though,