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