當前位置: 首頁>>代碼示例>>Python>>正文


Python Dataset.select方法代碼示例

本文整理匯總了Python中moztelemetry.dataset.Dataset.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Dataset.select方法的具體用法?Python Dataset.select怎麽用?Python Dataset.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moztelemetry.dataset.Dataset的用法示例。


在下文中一共展示了Dataset.select方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_select_dupe_properties

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import select [as 別名]
def test_select_dupe_properties():
    dataset = Dataset('test-bucket', ['dim1', 'dim2']).select('field1')

    with pytest.raises(Exception) as exc_info:
        dataset.select('field1')

    assert str(exc_info.value) == 'The property field1 has already been selected'

    with pytest.raises(Exception) as exc_info:
        dataset.select(field1='keyword_field')

    assert str(exc_info.value) == 'The property field1 has already been selected'
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:14,代碼來源:test_dataset.py

示例2: test_select

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import select [as 別名]
def test_select():
    dataset1 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', 'field2')
    dataset2 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', field2='field2')
    dataset3 = Dataset('test-bucket', ['dim1', 'dim2']).select(field1='field1', field2='field2')

    assert dataset1.selection == {
        'field1': 'field1',
        'field2': 'field2',
    }

    assert dataset1.selection == dataset2.selection == dataset3.selection

    dataset4 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', field2='f2', field3='f3')

    assert dataset4.selection == {
        'field1': 'field1',
        'field2': 'f2',
        'field3': 'f3',
    }

    dataset5 = dataset4.select('field4', field5='f5')

    assert dataset5.selection == {
        'field1': 'field1',
        'field2': 'f2',
        'field3': 'f3',
        'field4': 'field4',
        'field5': 'f5'
    }
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:31,代碼來源:test_dataset.py

示例3: test_select_keep_state

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import select [as 別名]
def test_select_keep_state():
    """Test that calling select only mutates the selection of a dataset"""
    dataset_before = Dataset('test-bucket', ['dim1', 'dim2']).where(dim1=True)
    dataset_after = dataset_before.select('field1', 'field2')

    assert dataset_before.selection != dataset_after.selection
    assert dataset_before.bucket == dataset_after.bucket
    assert dataset_before.schema == dataset_after.schema
    assert dataset_before.store == dataset_after.store
    assert dataset_before.prefix == dataset_after.prefix
    assert dataset_before.clauses == dataset_after.clauses
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:13,代碼來源:test_dataset.py

示例4: test_records_selection

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import select [as 別名]
def test_records_selection(spark_context):
    bucket_name = 'test-bucket'
    store = InMemoryStore(bucket_name)
    key = 'dir1/subdir1/key1'
    value = '{"a": {"b": { "c": "value"}}}'
    store.store[key] = value
    dataset = Dataset(bucket_name, ['dim1', 'dim2'], store=store).select(field='a.b.c')
    records = dataset.records(spark_context, decode=decode)
    assert records.collect() == [{'field': 'value'}]

    # Check that concatenating `select`s works as expected
    records = dataset.select(field2='a.b').records(spark_context, decode=decode)
    assert records.collect() == [{'field': 'value', 'field2': {'c': 'value'}}]
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:15,代碼來源:test_dataset.py


注:本文中的moztelemetry.dataset.Dataset.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。