Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/struct_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,23 @@ def test_struct_flatten_recursive(df):

df_flat = df.struct.flatten(recursive=False)
assert df_flat.get_column_names() == ['array_copy1', 'array_copy2', 'integer']


def test_struct_create():
data = {
'index': [1, 2, 3, 4, 5],
'value': [10, 20, 30, 40, 50],
'place': ['Amsterdam', 'London', 'Paris', 'Ohrid', 'Edinburgh'],
}

df = vaex.from_dict(data)

df['content'] = df.struct.create(['index', 'value', df.place])

assert df.shape == (5, 4)
assert df['content'].dtype == 'struct' # perhaps we should have a better way to check this

df['content_new_names'] = df.struct.create({'index': 'Index', 'value': 'Value', df.place: 'Location'})

assert df.shape == (5, 5)
assert df['content_new_names'].dtype == 'struct'