Example #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))
Example #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))
Example #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))
Example #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)
Example #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)
Example #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))
Example #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)
Example #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)
Example #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)
Example #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))
Example #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)
Example #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))