代码拉取完成,页面将自动刷新
name | about | labels |
---|---|---|
RFC | Use this template for the new feature or enhancement | kind/feature |
def __add__(self, datasets):
"""
Concat the datasets in the input list of datasets.
Note:
The column name,column data type and rank of column data should be the same in input datasets.
Args:
datasets (list or class Dataset): A list of datasets or a single class Dataset
to be concated together with this dataset.
Returns:
ConcatDataset, dataset concated.
Examples:
>>> import mindspore.dataset as ds
>>> # ds1 and ds2 are instances of Dataset object
>>> # creates a dataset by concating ds1 and ds2
>>> data1 = ds1 + ds2
"""
import mindspore.dataset as ds
def generator_3():
for i in range(3):
yield (np.array([i]), )
def generator_10():
for i in range(3, 10):
yield (np.array([i]), )
def test_concat_01():
"""
Test concat: test concat 2 datasets that have the same column name and data type
"""
data1 = ds.GeneratorDataset(generator_3, ["col1"])
data2 = ds.GeneratorDataset(generator_10, ["col1"])
data3 = data1 + data2
# Here i refers to index, d refers to data element
for i, d in enumerate(data3):
logger.info("data:", d[0][0])
assert i == d[0][0]
assert sum([1 for _ in data3]) == 10
0, 1, 2, 3, 4,5,6,7,8,9
Hey @ms_yan, Welcome to MindSpore Community.
All of the projects in MindSpore Community are maintained by @mindspore-ci-bot.
That means the developers can comment below every pull request or issue to trigger Bot Commands.
Please follow instructions at https://gitee.com/mindspore/community/blob/master/command.md to find the details.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论