Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#-*- coding: utf-8 -*- | ||
""" | ||
@brief test log(time=4s) | ||
""" | ||
|
||
import sys | ||
import os | ||
import unittest | ||
import pandas | ||
|
||
|
||
try: | ||
import pyquickhelper as skip_ | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
"..", | ||
"..", | ||
"pyquickhelper", | ||
"src"))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import pyquickhelper as skip_ | ||
|
||
|
||
try: | ||
import src | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
".."))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import src | ||
|
||
from pyquickhelper.loghelper import fLOG | ||
from pyquickhelper.pycode import ExtTestCase | ||
from src.pandas_streaming.df import dataframe_unfold | ||
|
||
|
||
class TestDataFrameHelpersSimple(ExtTestCase): | ||
|
||
def test_unfold(self): | ||
fLOG( | ||
__file__, | ||
self._testMethodName, | ||
OutputPrint=__name__ == "__main__") | ||
|
||
df = pandas.DataFrame([dict(a=1, b="e,f"), | ||
dict(a=2, b="g"), | ||
dict(a=3)]) | ||
df2 = dataframe_unfold(df, "b") | ||
|
||
exp = pandas.DataFrame([dict(a=1, b="e,f", b_unfold="e"), | ||
dict(a=1, b="e,f", b_unfold="f"), | ||
dict(a=2, b="g", b_unfold="g"), | ||
dict(a=3)]) | ||
self.assertEqualDataFrame(df2, exp) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters