本文整理汇总了Python中pyvttbl.DataFrame.keys方法的典型用法代码示例。如果您正苦于以下问题:Python DataFrame.keys方法的具体用法?Python DataFrame.keys怎么用?Python DataFrame.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvttbl.DataFrame
的用法示例。
在下文中一共展示了DataFrame.keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test12
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test12(self):
df=DataFrame()
df['DUM']=range(48) # Shouldn't complain
self.assertEqual(df.keys(),['DUM'])
df['DUM']=['A' for i in range(48)] # Shouldn't complain
self.assertEqual(df.keys(),['DUM'])
self.assertEqual(df._sqltypesdict['DUM'],'text')
示例2: test_kn
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test_kn(self):
df = DataFrame()
df.read_tbl('data/example.csv')
y = [23]*len(df['X'])
df['X'] = y
self.assertEqual(df.keys(), ['CASE', 'TIME', 'CONDITION', 'X'])
示例3: test4
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test4(self):
df = DataFrame()
df[1] = range(100)
df[2] = ["bob" for i in range(100)]
df[3] = [i * 1.234232 for i in range(100)]
df[4] = ["bob" for i in range(50)] + range(50)
with self.assertRaises(TypeError) as cm:
df._build_sqlite3_tbl(df.keys()[:2], 42)
self.assertEqual(str(cm.exception), "'int' object is not iterable")
示例4: test3
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test3(self):
tupa = ('a1','a2','a3')
tupb = ('a1','b2','b3')
df=DataFrame()
df.insert([(('a1','a2','a3'),34), (('a1','b2','b3'),1)])
df.insert([(('a1','a2','a3'),34), (('a1','b2','b3'),2)])
df.insert([(('a1','a2','a3'),42), (('a1','b2','b3'),3)])
namea,nameb = df.keys()
self.assertEqual(namea, tupa)
self.assertEqual(nameb, tupb)
示例5: test31
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test31(self):
df = DataFrame()
df[1] = range(100)
df[2] = ["bob" for i in range(100)]
df[3] = [i * 1.234232 for i in range(100)]
df[4] = ["bob" for i in range(50)] + range(50)
shuffle(df[1])
shuffle(df[2])
shuffle(df[3])
with self.assertRaises(KeyError) as cm:
df._build_sqlite3_tbl(df.keys()[:2], ['4 != "bob"'])
self.assertEqual(str(cm.exception), "'4'")
示例6: test1
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test1(self):
R = {'DUM': 'integer',
'COURSE': 'text',
'ERROR': 'integer',
'MODEL': 'text',
'TIMEOFDAY': 'text',
'SUBJECT': 'integer'}
df=DataFrame()
df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
df['DUM']=range(48) # Shouldn't complain
self.assertEqual(df.keys(),
['SUBJECT', 'TIMEOFDAY', 'COURSE', 'MODEL', 'ERROR', 'DUM'])
for k in R:
self.assertEqual(df._sqltypesdict[k],R[k])
示例7: Test_del_item
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
class Test_del_item(unittest.TestCase):
def setUp(self):
self.df=DataFrame()
self.df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
del self.df['COURSE']
def test0(self):
self.assertEqual(self.df.keys(),
['SUBJECT', 'TIMEOFDAY', 'MODEL', 'ERROR'])
def test1(self):
self.assertEqual(list(self.df.types()),
['integer', 'text', 'text', 'integer'])
def test3(self):
self.assertEqual(len(self.df), 4)
示例8: test3
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test3(self):
"""test with string keys and tuple where condition"""
df = DataFrame()
df[1] = range(100)
df[2] = ["bob" for i in range(100)]
df[3] = [i * 1.234232 for i in range(100)]
df[4] = ["bob" for i in range(50)] + range(50)
shuffle(df[1])
shuffle(df[2])
shuffle(df[3])
df._build_sqlite3_tbl(df.keys()[:2], [(4, "!=", "bob")])
df._execute("select * from TBL")
for i, (a, b) in enumerate(df.cur):
self.assertEqual(a, df[1][i + 50])
self.assertEqual(b, df[2][i + 50])
示例9: test22
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test22(self):
"""test with string keys and where condition"""
df = DataFrame()
df["1"] = range(100)
df["2"] = ["bob" for i in range(100)]
df["3"] = [i * 1.234232 for i in range(100)]
df["4"] = ["bob" for i in range(50)] + range(50)
shuffle(df["1"])
shuffle(df["2"])
shuffle(df["3"])
df._build_sqlite3_tbl(df.keys()[:2], ['4 not in ("bob")'])
df._execute("select * from TBL")
for i, (a, b) in enumerate(df.cur):
self.assertEqual(a, df["1"][i + 50])
self.assertEqual(b, df["2"][i + 50])
示例10: test1
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test1(self):
"""test with integer keys subset of table"""
df = DataFrame()
df[1] = range(100)
df[2] = ["bob" for i in range(100)]
df[3] = [i * 1.234232 for i in range(100)]
df[4] = ["bob" for i in range(50)] + range(50)
shuffle(df[1])
shuffle(df[2])
shuffle(df[3])
shuffle(df[4])
df._build_sqlite3_tbl(df.keys()[:2])
df._execute("select * from TBL")
for i, (a, b) in enumerate(df.cur):
self.assertEqual(a, df[1][i])
self.assertEqual(b, df[2][i])
示例11: test2
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test2(self):
df1=DataFrame()
df2=DataFrame()
df1.read_tbl('data/words~ageXcondition.csv')
df2.read_tbl('data/words~ageXcondition.csv')
M=df1.shape()[1]
# this should work
df1.attach(df2)
# df1 should have twice as many rows now
self.assertEqual(df1.shape()[1]/2,df2.shape()[1])
# go through and check data
for i in range(M):
for n in df1.keys():
if _isfloat(df1[n][i]):
self.assertAlmostEqual(df1[n][i],df1[n][M+i])
else:
self.assertEqual(df1[n][i],df1[n][M+i])
示例12: test02
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test02(self):
"""test with tuple keys"""
df = DataFrame()
## df.PRINTQUERIES = True
df[(1,)] = range(100)
df[(2,)] = ["bob" for i in range(100)]
df[(3,)] = [i * 1.234232 for i in range(100)]
df[(4,)] = ["bob" for i in range(50)] + range(50)
shuffle(df[(1,)])
shuffle(df[(2,)])
shuffle(df[(3,)])
shuffle(df[(4,)])
df._build_sqlite3_tbl(df.keys())
df._execute("select * from TBL")
for i, (a, b, c, d) in enumerate(df.cur):
self.assertEqual(a, df[(1,)][i])
self.assertEqual(b, df[(2,)][i])
self.assertEqual(c, df[(3,)][i])
self.assertEqual(d, str(df[(4,)][i]))
示例13: test00
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test00(self):
"""test with string keys"""
df = DataFrame()
## df.PRINTQUERIES=True
df["1"] = range(100)
df["2"] = ["bob" for i in range(100)]
df["3"] = [i * 1.234232 for i in range(100)]
df["4"] = ["bob" for i in range(50)] + range(50)
df["5"] = np.sqrt(df["3"] * 100.0)
## print(df)
shuffle(df["1"])
shuffle(df["2"])
shuffle(df["3"])
df._build_sqlite3_tbl(df.keys())
df._execute("select * from TBL")
for i, (a, b, c, d, e) in enumerate(df.cur):
self.assertEqual(a, df["1"][i])
self.assertEqual(b, df["2"][i])
self.assertEqual(c, df["3"][i])
self.assertEqual(d, str(df["4"][i]))
示例14: test21
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test21(self):
df=DataFrame()
df[1]=range(48)
df[2]=['A' for i in range(48)]
self.assertEqual(df.keys(),[1,2])
示例15: test11
# 需要导入模块: from pyvttbl import DataFrame [as 别名]
# 或者: from pyvttbl.DataFrame import keys [as 别名]
def test11(self):
df=DataFrame()
df['DUM']=range(48) # Shouldn't complain
self.assertEqual(df.keys(),['DUM'])