Пример #1
0
 def testDataPyWithListOfDict(self):
     src = [{'a': 1, 'b': 3}, {'a': 2, 'b': 4}]
     datao = pygg.data_py(src)
     dffile, expr = datao.fname, str(datao)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(pandas.DataFrame({'a': [1, 2], 'b': [3, 4]}),
                            pandas.read_csv(dffile))
Пример #2
0
 def testDataPyWithListOfDict(self):
     src = [{'a': 1, 'b': 3}, {'a': 2, 'b': 4}]
     datao = pygg.data_py(src)
     dffile, expr = datao.fname, str(datao)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(pandas.DataFrame({
         'a': [1, 2],
         'b': [3, 4]
     }), pandas.read_csv(dffile))
Пример #3
0
 def testDataPyWithString(self):
     src = "my.csv"
     dffile, expr = pygg.data_py(src)
     self.assertEquals(dffile, src)
     self.assertEquals(expr, 'data = read.csv("{}",sep=",")'.format(src))
Пример #4
0
 def testDataPyWithDict(self):
     src = {'a': [1, 2], 'b': [3, 4]}
     dffile, expr = pygg.data_py(src)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(pandas.DataFrame(src), iodf)
Пример #5
0
 def testDataPyLoadStmtArgs(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     dffile, expr = pygg.data_py(df, 1, kwd=2)
     expected = 'data = read.csv("{}",1,kwd=2,sep=",")'.format(dffile)
     self.assertEquals(expr, expected)
Пример #6
0
 def testDataPyLoadStmtPlain(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     dffile, expr = pygg.data_py(df)
     self.assertEquals(expr,
                       'data = read.csv("{}",sep=",")'.format(dffile))
Пример #7
0
 def testDataPyWithDF(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     dffile, expr = pygg.data_py(df)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(df, iodf)
Пример #8
0
 def testDataPyWithDict(self):
     src = {'a': [1, 2], 'b': [3, 4]}
     datao = pygg.data_py(src)
     dffile, expr = datao.fname, str(datao)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(pandas.DataFrame(src), iodf)
Пример #9
0
 def testDataPyLoadStmtArgs(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     datao = pygg.data_py(df, 1, kwd=2)
     dffile, expr = datao.fname, str(datao)
     expected = 'data = read.csv("{}",1,kwd=2,sep=",")'.format(dffile)
     self.assertEquals(expr, expected)
Пример #10
0
 def testDataPyLoadStmtPlain(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     datao = pygg.data_py(df)
     dffile, expr = datao.fname, str(datao)
     self.assertEquals(expr, 'data = read.csv("{}",sep=",")'.format(dffile))
Пример #11
0
 def testDataPyWithDF(self):
     df = pandas.DataFrame({'a': [1, 2], 'b': [3, 4]})
     datao = pygg.data_py(df)
     dffile, expr = datao.fname, str(datao)
     iodf = pandas.read_csv(dffile)
     pdt.assert_frame_equal(df, iodf)
Пример #12
0
 def testDataPyWithString(self):
     src = "my.csv"
     datao = pygg.data_py(src)
     dffile, expr = datao.fname, str(datao)
     self.assertEquals(dffile, src)
     self.assertEquals(expr, 'data = read.csv("{}",sep=",")'.format(src))