cudf.core.column.string.StringMethods.get_json_object#

StringMethods.get_json_object(json_path, *, allow_single_quotes=False, strip_quotes_from_single_strings=True, missing_fields_as_nulls=False)[source]#

将JSONPath字符串应用于输入字符串列,其中列中的每一行都是有效的json字符串

Parameters:
json_pathstr

要应用于输入列的每一行的JSONPath字符串

allow_single_quotesbool, default False

如果为True,允许使用单引号表示字符串。 如果为False,字符串必须仅使用双引号表示。

strip_quotes_from_single_stringsbool, default True

如果为True,则从给定行的返回值中去除引号(如果它是字符串)。 如果为False,则给定行返回的值如果为字符串则包含引号。

missing_fields_as_nullsbool, default False

如果为True,当查询对象不包含的字段时,返回“null”。 如果为False,当查询对象不包含的字段时,返回None。

Returns:
Column: New strings column containing the retrieved json object strings

示例

>>> import cudf
>>> s = cudf.Series(
    [
        \"\"\"
        {
            "store":{
                "book":[
                    {
                        "category":"reference",
                        "author":"Nigel Rees",
                        "title":"Sayings of the Century",
                        "price":8.95
                    },
                    {
                        "category":"fiction",
                        "author":"Evelyn Waugh",
                        "title":"Sword of Honour",
                        "price":12.99
                    }
                ]
            }
        }
        \"\"\"
    ])
>>> s
    0    {"store": {\n        "book": [\n        { "cat...
    dtype: object
>>> s.str.get_json_object("$.store.book")
    0    [\n        { "category": "reference",\n       ...
    dtype: object