本文整理汇总了Python中odo.append函数的典型用法代码示例。如果您正苦于以下问题:Python append函数的具体用法?Python append怎么用?Python append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了append函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_drop
def test_drop():
with tmpfile('json') as fn:
js = JSON(fn)
append(js, [1, 2, 3])
assert os.path.exists(fn)
drop(js)
assert not os.path.exists(fn)
开发者ID:CaptainAL,项目名称:Spyder,代码行数:8,代码来源:test_json.py
示例2: test_append_convert
def test_append_convert(empty_bank, raw_bank):
ds = discover(raw_bank)
assert set(ds.measure.names) == {'name', 'amount'}
append(empty_bank, raw_bank, dshape=ds)
assert odo(empty_bank, list, dshape=ds) == list(
pluck(ds.measure.names, raw_bank)
)
开发者ID:Curezhang,项目名称:odo,代码行数:8,代码来源:test_mongo.py
示例3: test_table_resource
def test_table_resource():
with tmpfile('csv') as filename:
ds = dshape('var * {a: int, b: int}')
csv = CSV(filename)
append(csv, [[1, 2], [10, 20]], dshape=ds)
t = Data(filename)
assert isinstance(t.data, CSV)
assert into(list, compute(t)) == into(list, csv)
开发者ID:postelrich,项目名称:blaze,代码行数:9,代码来源:test_interactive.py
示例4: test_append_json
def test_append_json():
with tmpfile('json') as fn:
j = JSON(fn)
append(j, dat)
with open(j.path) as f:
lines = f.readlines()
assert len(lines) == 1
assert 'Alice' in lines[0]
assert 'Bob' in lines[0]
开发者ID:CaptainAL,项目名称:Spyder,代码行数:9,代码来源:test_json.py
示例5: test_csv_to_s3_append
def test_csv_to_s3_append():
df = tm.makeMixedDataFrame()
with tmpfile('.csv') as fn:
with s3_bucket('.csv') as b:
s3 = resource(b)
df.to_csv(fn, index=False)
append(s3, CSV(fn))
result = into(pd.DataFrame, s3)
tm.assert_frame_equal(df, result)
开发者ID:hussainsultan,项目名称:odo,代码行数:9,代码来源:test_aws.py
示例6: test_write_gzip_lines
def test_write_gzip_lines():
with tmpfile('json.gz') as fn:
j = JSONLines(fn)
append(j, dat)
f = gzip.open(fn)
line = next(f)
f.close()
assert line.decode('utf-8').strip() == str(json.dumps(dat[0]))
开发者ID:CaptainAL,项目名称:Spyder,代码行数:9,代码来源:test_json.py
示例7: test_append_sas_to_sqlite_round_trip
def test_append_sas_to_sqlite_round_trip():
expected = convert(set, sasfile)
with tmpfile('db') as fn:
r = resource('sqlite:///%s::SAS' % fn, dshape=discover(sasfile))
append(r, sasfile)
result = convert(set, r)
assert expected == result
开发者ID:CaptainAL,项目名称:Spyder,代码行数:10,代码来源:test_sas.py
示例8: test_write_gzip
def test_write_gzip():
with tmpfile('json.gz') as fn:
j = JSON(fn)
append(j, dat)
f = gzip.open(fn)
text = f.read()
f.close()
assert text.decode('utf-8').strip() == str(json.dumps(dat))
assert isinstance(resource(fn), (JSON, JSONLines))
开发者ID:CaptainAL,项目名称:Spyder,代码行数:10,代码来源:test_json.py
示例9: test_datetimes
def test_datetimes():
from odo import into
import numpy as np
data = [{'a': 1, 'dt': datetime.datetime(2001, 1, 1)},
{'a': 2, 'dt': datetime.datetime(2002, 2, 2)}]
with tmpfile('json') as fn:
j = JSONLines(fn)
append(j, data)
assert str(into(np.ndarray, j)) == str(into(np.ndarray, data))
开发者ID:CaptainAL,项目名称:Spyder,代码行数:10,代码来源:test_json.py
示例10: test_append_and_convert_round_trip
def test_append_and_convert_round_trip():
engine = sa.create_engine("sqlite:///:memory:")
metadata = sa.MetaData(engine)
t = sa.Table("bank", metadata, sa.Column("name", sa.String, primary_key=True), sa.Column("balance", sa.Integer))
t.create()
data = [("Alice", 1), ("Bob", 2)]
append(t, data)
assert convert(list, t) == data
开发者ID:hussainsultan,项目名称:odo,代码行数:10,代码来源:test_sql.py
示例11: test_append_and_convert_round_trip
def test_append_and_convert_round_trip():
engine = sa.create_engine('sqlite:///:memory:')
metadata = sa.MetaData(engine)
t = sa.Table('bank', metadata,
sa.Column('name', sa.String, primary_key=True),
sa.Column('balance', sa.Integer))
t.create()
data = [('Alice', 1), ('Bob', 2)]
append(t, data)
assert convert(list, t) == data
开发者ID:EGQM,项目名称:odo,代码行数:12,代码来源:test_sql.py
示例12: test_tuples_to_json
def test_tuples_to_json():
ds = dshape('var * {a: int, b: int}')
with tmpfile('json') as fn:
j = JSON(fn)
append(j, [(1, 2), (10, 20)], dshape=ds)
with open(fn) as f:
assert '"a": 1' in f.read()
with tmpfile('json') as fn:
j = JSONLines(fn)
append(j, [(1, 2), (10, 20)], dshape=ds)
with open(fn) as f:
assert '"a": 1' in f.read()
开发者ID:CaptainAL,项目名称:Spyder,代码行数:15,代码来源:test_json.py
示例13: test_select_to_iterator
def test_select_to_iterator():
engine, t = single_table_engine()
append(t, [('Alice', 100), ('Bob', 200)])
sel = sa.select([t.c.amount + 1])
assert convert(list, sel) == [(101,), (201,)]
assert convert(list, sel, dshape=dshape('var * int')) == [101, 201]
sel2 = sa.select([sa.sql.func.sum(t.c.amount)])
assert convert(int, sel2, dshape=dshape('int')) == 300
sel3 = sa.select([t])
result = convert(list, sel3, dshape=discover(t))
assert type(result[0]) is tuple
开发者ID:jhyun0919,项目名称:ML-DL_jhyun,代码行数:17,代码来源:test_sql.py
示例14: test_into_table_iterator
def test_into_table_iterator():
engine = sa.create_engine("sqlite:///:memory:")
metadata = sa.MetaData(engine)
t = dshape_to_table("points", "{x: int, y: int}", metadata=metadata)
t.create()
data = [(1, 1), (2, 4), (3, 9)]
append(t, data)
assert convert(list, t) == data
assert isinstance(convert(list, t)[0], tuple)
t2 = dshape_to_table("points2", "{x: int, y: int}", metadata=metadata)
t2.create()
data2 = [{"x": 1, "y": 1}, {"x": 2, "y": 4}, {"x": 3, "y": 9}]
append(t2, data2)
assert convert(list, t2) == data
开发者ID:hussainsultan,项目名称:odo,代码行数:18,代码来源:test_sql.py
示例15: test_append_from_select
def test_append_from_select(sqlite_file):
# we can't test in memory here because that creates two independent
# databases
raw = np.array([(200.0, "Glenn"), (314.14, "Hope"), (235.43, "Bob")], dtype=[("amount", "float64"), ("name", "S5")])
raw2 = np.array(
[(800.0, "Joe"), (914.14, "Alice"), (1235.43, "Ratso")], dtype=[("amount", "float64"), ("name", "S5")]
)
t = into("%s::t" % sqlite_file, raw)
s = into("%s::s" % sqlite_file, raw2)
t = append(t, s.select())
result = into(list, t)
expected = np.concatenate((raw, raw2)).tolist()
assert result == expected
开发者ID:hussainsultan,项目名称:odo,代码行数:13,代码来源:test_sql.py
示例16: test_append_from_table
def test_append_from_table():
# we can't test in memory here because that creates two independent
# databases
with tmpfile("db") as fn:
raw = np.array(
[(200.0, "Glenn"), (314.14, "Hope"), (235.43, "Bob")], dtype=[("amount", "float64"), ("name", "S5")]
)
raw2 = np.array(
[(800.0, "Joe"), (914.14, "Alice"), (1235.43, "Ratso")], dtype=[("amount", "float64"), ("name", "S5")]
)
t = into("sqlite:///%s::t" % fn, raw)
s = into("sqlite:///%s::s" % fn, raw2)
t = append(t, s)
result = odo(t, list)
expected = np.concatenate((raw, raw2)).tolist()
assert result == expected
开发者ID:hussainsultan,项目名称:odo,代码行数:16,代码来源:test_sql.py
示例17: test_append_from_select
def test_append_from_select(sqlite_file):
# we can't test in memory here because that creates two independent
# databases
raw = np.array([(200.0, 'Glenn'),
(314.14, 'Hope'),
(235.43, 'Bob')], dtype=[('amount', 'float64'),
('name', 'U5')])
raw2 = np.array([(800.0, 'Joe'),
(914.14, 'Alice'),
(1235.43, 'Ratso')], dtype=[('amount', 'float64'),
('name', 'U5')])
t = into('%s::t' % sqlite_file, raw)
s = into('%s::s' % sqlite_file, raw2)
t = append(t, s.select())
result = into(list, t)
expected = np.concatenate((raw, raw2)).tolist()
assert result == expected
开发者ID:EGQM,项目名称:odo,代码行数:17,代码来源:test_sql.py
示例18: test_append_from_table
def test_append_from_table():
# we can't test in memory here because that creates two independent
# databases
with tmpfile('db') as fn:
raw = np.array([(200.0, 'Glenn'),
(314.14, 'Hope'),
(235.43, 'Bob')], dtype=[('amount', 'float64'),
('name', 'U5')])
raw2 = np.array([(800.0, 'Joe'),
(914.14, 'Alice'),
(1235.43, 'Ratso')], dtype=[('amount', 'float64'),
('name', 'U5')])
t = into('sqlite:///%s::t' % fn, raw)
s = into('sqlite:///%s::s' % fn, raw2)
t = append(t, s)
result = odo(t, list)
expected = np.concatenate((raw, raw2)).tolist()
assert result == expected
开发者ID:EGQM,项目名称:odo,代码行数:18,代码来源:test_sql.py
示例19: test_sql_field_names_disagree_on_names
def test_sql_field_names_disagree_on_names():
r = resource('sqlite:///:memory:::tb', dshape=dshape('{x: int, y: int}'))
assert raises(Exception, lambda: append(r, [(1, 2), (10, 20)],
dshape=dshape('{x: int, z: int}')))
开发者ID:EGQM,项目名称:odo,代码行数:4,代码来源:test_sql.py
示例20: test_sql_field_names_disagree_on_order
def test_sql_field_names_disagree_on_order():
r = resource('sqlite:///:memory:::tb', dshape=dshape('{x: int, y: int}'))
append(r, [(1, 2), (10, 20)], dshape=dshape('{y: int, x: int}'))
assert convert(set, r) == set([(2, 1), (20, 10)])
开发者ID:EGQM,项目名称:odo,代码行数:4,代码来源:test_sql.py
注:本文中的odo.append函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论