rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.45k stars 908 forks source link

[BUG] json reader reading in string Series with newlines has "\\n" instead of "\n" #9052

Closed jfurtek closed 1 year ago

jfurtek commented 3 years ago

Describe the bug Retrieving strings that contain a newline character from a Series returns a string with an "escaped" backslash (\\n) instead of \n. The cudf output does not match the equivalent pandas output.

Steps/Code to reproduce bug 1.) Create a JSON file with the following contents, called test.json:

{"value": 16, "data": "thirty_chars_plus_two_newlines\n\n" }
{"value": 19, "data": "more_data_with_newline\r\n"}

2.) Create dataframes using both Pandas and cuDF, and compare the output of extracting a single element from a series:

>>> import pandas as pd
>>> import cudf
>>> df_pd = pd.read_json('test.json', lines=True)
>>> df_cudf = cudf.read_json('test.json', lines=True)
>>> df_pd
df_pd
   value                                data
0     16  thirty_chars_plus_two_newlines\n\n
1     19          more_data_with_newline\r\n
>>> df_cudf
df_cudf
   value                                data
0     16  thirty_chars_plus_two_newlines\n\n
1     19          more_data_with_newline\r\n

(THE OUTPUT OF THE NEXT TWO LINES SHOULD MATCH...)
>>> df_pd['data'][0]
'thirty_chars_plus_two_newlines\n\n'
>>> df_cudf['data'][0]
'thirty_chars_plus_two_newlines\\n\\n'

>>> len(df_pd['data'][0])
32
>>> len(df_cudf['data'][0])
34

>>> df_pd['data'][1]
'more_data_with_newline\r\n'
>>> df_cudf['data'][1]
'more_data_with_newline\r\\n'

Expected behavior The output should match pandas output.

Environment overview (please complete the following information)

Environment details

<details><summary>Click here to see environment details</summary><pre>

     **git***
     commit 0ddee24e888cbcf68c7f5191e3c87bb3a65283b7 (HEAD -> branch-0.1.1-EA, tag: v0.1.1, origin/branch-0.1.1-EA)
     Merge: 8bdb04b a0bb551
     Author: Michael Demoret <mdemoret@nvidia.com>
     Date:   Fri Jul 30 21:37:15 2021 +0000

     Merge branch 'update-abp-pcap-example' into 'branch-0.1.1-EA'

     Updates to ABP PCAP Detection Example

     See merge request morpheus/morpheus!37
     **git submodules***
     b1d0b7f476b1d3dd5d6f147ba26d0879f949d8e0 ../../models (v0.2.0a)

     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=18.04
     DISTRIB_CODENAME=bionic
     DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
     NAME="Ubuntu"
     VERSION="18.04.5 LTS (Bionic Beaver)"
     ID=ubuntu
     ID_LIKE=debian
     PRETTY_NAME="Ubuntu 18.04.5 LTS"
     VERSION_ID="18.04"
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     VERSION_CODENAME=bionic
     UBUNTU_CODENAME=bionic
     Linux jfurtek-dt 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

     ***GPU Information***
     Tue Aug 17 15:54:26 2021
     +-----------------------------------------------------------------------------+
     | NVIDIA-SMI 470.57.02    Driver Version: 470.57.02    CUDA Version: 11.4     |
     |-------------------------------+----------------------+----------------------+
     | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
     |                               |                      |               MIG M. |
     |===============================+======================+======================|
     |   0  Quadro GP100        Off  | 00000000:01:00.0  On |                  Off |
     | 31%   47C    P0    26W / 235W |    710MiB / 16277MiB |      3%      Default |
     |                               |                      |                  N/A |
     +-------------------------------+----------------------+----------------------+

     +-----------------------------------------------------------------------------+
     | Processes:                                                                  |
     |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
     |        ID   ID                                                   Usage      |
     |=============================================================================|
     +-----------------------------------------------------------------------------+

     ***CPU***
     Architecture:        x86_64
     CPU op-mode(s):      32-bit, 64-bit
     Byte Order:          Little Endian
     CPU(s):              12
     On-line CPU(s) list: 0-11
     Thread(s) per core:  2
     Core(s) per socket:  6
     Socket(s):           1
     NUMA node(s):        1
     Vendor ID:           GenuineIntel
     CPU family:          6
     Model:               63
     Model name:          Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
     Stepping:            2
     CPU MHz:             1204.615
     CPU max MHz:         3600.0000
     CPU min MHz:         1200.0000
     BogoMIPS:            6596.14
     Virtualization:      VT-x
     L1d cache:           32K
     L1i cache:           32K
     L2 cache:            256K
     L3 cache:            15360K
     NUMA node0 CPU(s):   0-11
     Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts md_clear flush_l1d

     ***CMake***

     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
     Copyright (C) 2017 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     ***nvcc***
     /usr/local/cuda/bin/nvcc
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2021 NVIDIA Corporation
     Built on Sun_Feb_14_21:12:58_PST_2021
     Cuda compilation tools, release 11.2, V11.2.152
     Build cuda_11.2.r11.2/compiler.29618528_0

     ***Python***
     /opt/conda/envs/morpheus/bin/python
     Python 3.8.10

     ***Environment Variables***
     PATH                            : /opt/conda/envs/morpheus/bin:/opt/conda/condabin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     LD_LIBRARY_PATH                 : /usr/local/nvidia/lib:/usr/local/nvidia/lib64
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    : /opt/conda/envs/morpheus
     PYTHON_PATH                     :

     ***conda packages***
     /opt/conda/condabin/conda
     # packages in environment at /opt/conda/envs/morpheus:
     #
     # Name                    Version                   Build  Channel
     _libgcc_mutex             0.1                 conda_forge    conda-forge
     _openmp_mutex             4.5                       1_gnu    conda-forge
     abseil-cpp                20210324.2           h9c3ff4c_0    conda-forge
     alabaster                 0.7.12                     py_0    conda-forge
     appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
     arrow-cpp                 1.0.1           py38h08fe832_44_cuda    conda-forge
     arrow-cpp-proc            3.0.0                      cuda    conda-forge
     asn1crypto                1.4.0              pyh9f0ad1d_0    conda-forge
     atk-1.0                   2.36.0               h3371d22_4    conda-forge
     attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
     aws-c-cal                 0.5.11               h95a6274_0    conda-forge
     aws-c-common              0.6.2                h7f98852_0    conda-forge
     aws-c-event-stream        0.2.7               h3541f99_13    conda-forge
     aws-c-io                  0.10.5               hfb6a706_0    conda-forge
     aws-checksums             0.1.11               ha31a3da_7    conda-forge
     aws-sdk-cpp               1.8.186              hb4091e7_3    conda-forge
     babel                     2.9.1              pyh44b312d_0    conda-forge
     bokeh                     2.3.3            py38h578d9bd_0    conda-forge
     brotli                    1.0.9                h7f98852_5    conda-forge
     brotli-bin                1.0.9                h7f98852_5    conda-forge
     brotlipy                  0.7.0           py38h497a2fe_1001    conda-forge
     bzip2                     1.0.8                h7f98852_4    conda-forge
     c-ares                    1.17.1               h7f98852_1    conda-forge
     ca-certificates           2021.5.30            ha878542_0    conda-forge
     cached-property           1.5.2                hd8ed1ab_1    conda-forge
     cached_property           1.5.2              pyha770c72_1    conda-forge
     cachetools                4.2.2              pyhd8ed1ab_0    conda-forge
     cairo                     1.16.0            h6cf1ce9_1008    conda-forge
     certifi                   2021.5.30        py38h578d9bd_0    conda-forge
     cffi                      1.14.6           py38ha65f79e_0    conda-forge
     chardet                   4.0.0            py38h578d9bd_1    conda-forge
     charset-normalizer        2.0.0              pyhd8ed1ab_0    conda-forge
     click                     7.1.2                    pypi_0    pypi
     click-completion          0.5.2                    pypi_0    pypi
     cloudpickle               1.6.0                      py_0    conda-forge
     colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
     configargparse            1.5.1                    pypi_0    pypi
     cryptography              3.4.7            py38ha5dfef3_0    conda-forge
     cudatoolkit               11.2.72              h2bc3f7f_0    nvidia
     cudf                      21.06.01        cuda_11.2_py38_g101fc0fda4_2    rapidsai
     cudf_kafka                21.06.01        py38_g101fc0fda4_2    rapidsai
     cuml                      21.06.02        cuda11.2_py38_g7dfbf8d9e_0    rapidsai
     cupy                      9.2.0            py38ha69542f_0    conda-forge
     custreamz                 21.06.01        py38_g101fc0fda4_2    rapidsai
     cyrus-sasl                2.1.27               h230043b_2    conda-forge
     cytoolz                   0.11.0           py38h497a2fe_3    conda-forge
     dask                      2021.5.1           pyhd8ed1ab_0    conda-forge
     dask-core                 2021.5.1           pyhd8ed1ab_0    conda-forge
     dask-cudf                 21.06.01        py38_g101fc0fda4_2    rapidsai
     distributed               2021.5.1         py38h578d9bd_0    conda-forge
     distro                    1.5.0              pyh9f0ad1d_0    conda-forge
     dlpack                    0.5                  h9c3ff4c_0    conda-forge
     docker-compose            1.29.2           py38h578d9bd_0    conda-forge
     docker-py                 5.0.0            py38h578d9bd_0    conda-forge
     docker-pycreds            0.4.0                      py_0    conda-forge
     dockerpty                 0.4.1                      py_0    conda-forge
     docopt                    0.6.2                      py_1    conda-forge
     docutils                  0.17.1                   pypi_0    pypi
     expat                     2.4.1                h9c3ff4c_0    conda-forge
     faiss-proc                1.0.0                      cuda    rapidsai
     faker                     8.10.3             pyhd8ed1ab_0    conda-forge
     fastavro                  1.4.4            py38h497a2fe_0    conda-forge
     fastrlock                 0.6              py38h709712a_1    conda-forge
     font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
     font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
     font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
     font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
     fontconfig                2.13.1            hba837de_1005    conda-forge
     fonts-conda-ecosystem     1                             0    conda-forge
     fonts-conda-forge         1                             0    conda-forge
     freetype                  2.10.4               h0708190_1    conda-forge
     fribidi                   1.0.10               h36c2ea0_0    conda-forge
     fsspec                    2021.7.0           pyhd8ed1ab_0    conda-forge
     gdk-pixbuf                2.42.6               h04a7f16_0    conda-forge
     gettext                   0.19.8.1          h0b5b191_1005    conda-forge
     gevent                    21.1.2                   pypi_0    pypi
     geventhttpclient          1.4.4                    pypi_0    pypi
     gflags                    2.2.2             he1b5a44_1004    conda-forge
     giflib                    5.2.1                h36c2ea0_2    conda-forge
     glog                      0.5.0                h48cff8f_0    conda-forge
     graphite2                 1.3.13            h58526e2_1001    conda-forge
     graphviz                  2.48.0               h85b4f2f_0    conda-forge
     greenlet                  1.1.0                    pypi_0    pypi
     grpc-cpp                  1.39.0               h36ce80c_1    conda-forge
     grpcio                    1.39.0                   pypi_0    pypi
     grpcio-channelz           1.39.0                   pypi_0    pypi
     gtk2                      2.24.33              h539f30e_1    conda-forge
     gts                       0.7.6                h64030ff_2    conda-forge
     harfbuzz                  2.8.2                h83ec7ef_0    conda-forge
     heapdict                  1.0.1                      py_0    conda-forge
     icu                       68.1                 h58526e2_0    conda-forge
     idna                      3.1                pyhd3deb0d_0    conda-forge
     imagesize                 1.2.0                      py_0    conda-forge
     importlib-metadata        4.6.3            py38h578d9bd_0    conda-forge
     importlib_metadata        4.6.3                hd8ed1ab_0    conda-forge
     jbig                      2.1               h7f98852_2003    conda-forge
     jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
     joblib                    1.0.1              pyhd8ed1ab_0    conda-forge
     jpeg                      9d                   h36c2ea0_0    conda-forge
     jsonschema                3.2.0            py38h32f6830_1    conda-forge
     krb5                      1.19.2               hcc1bbae_0    conda-forge
     lcms2                     2.12                 hddcbb42_0    conda-forge
     ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
     lerc                      2.2.1                h9c3ff4c_0    conda-forge
     libblas                   3.9.0               10_openblas    conda-forge
     libbrotlicommon           1.0.9                h7f98852_5    conda-forge
     libbrotlidec              1.0.9                h7f98852_5    conda-forge
     libbrotlienc              1.0.9                h7f98852_5    conda-forge
     libcblas                  3.9.0               10_openblas    conda-forge
     libcudf                   21.06.01        cuda11.2_g101fc0fda4_2    rapidsai
     libcudf_kafka             21.06.01          g101fc0fda4_2    rapidsai
     libcuml                   21.06.02        cuda11.2_g7dfbf8d9e_0    rapidsai
     libcumlprims              21.06.00        cuda11.2_gfda2e6c_0    nvidia
     libcurl                   7.78.0               h2574ce0_0    conda-forge
     libdeflate                1.7                  h7f98852_5    conda-forge
     libedit                   3.1.20191231         he28a2e2_2    conda-forge
     libev                     4.33                 h516909a_1    conda-forge
     libevent                  2.1.10               hcdb4288_3    conda-forge
     libfaiss                  1.7.0           cuda112h5bea7ad_8_cuda    conda-forge
     libffi                    3.3                  h58526e2_2    conda-forge
     libgcc-ng                 11.1.0               hc902ee8_6    conda-forge
     libgcrypt                 1.9.3                h7f98852_1    conda-forge
     libgd                     2.3.2                h78a0170_0    conda-forge
     libgfortran-ng            11.1.0               h69a702a_6    conda-forge
     libgfortran5              11.1.0               h6c583b3_6    conda-forge
     libglib                   2.68.3               h3e27bee_0    conda-forge
     libgomp                   11.1.0               hc902ee8_6    conda-forge
     libgpg-error              1.42                 h9c3ff4c_0    conda-forge
     libgsasl                  1.8.0                         2    conda-forge
     libhwloc                  2.3.0                h5e5b7d1_1    conda-forge
     libiconv                  1.16                 h516909a_0    conda-forge
     liblapack                 3.9.0               10_openblas    conda-forge
     libllvm10                 10.0.1               he513fc3_3    conda-forge
     libnghttp2                1.43.0               h812cca2_0    conda-forge
     libntlm                   1.4               h7f98852_1002    conda-forge
     libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
     libpng                    1.6.37               h21135ba_2    conda-forge
     libprotobuf               3.16.0               h780b84a_0    conda-forge
     librdkafka                1.5.3                hc49e61c_1    conda-forge
     librmm                    21.06.00        cuda11.2_gee432a0_0    rapidsai
     librsvg                   2.50.7               hc3c00ef_0    conda-forge
     libssh2                   1.9.0                ha56f1ee_6    conda-forge
     libstdcxx-ng              11.1.0               h56837e0_6    conda-forge
     libthrift                 0.14.2               he6d91bd_1    conda-forge
     libtiff                   4.3.0                hf544144_1    conda-forge
     libtool                   2.4.6             h58526e2_1007    conda-forge
     libutf8proc               2.6.1                h7f98852_0    conda-forge
     libuuid                   2.32.1            h7f98852_1000    conda-forge
     libwebp                   1.2.0                h3452ae3_0    conda-forge
     libwebp-base              1.2.0                h7f98852_2    conda-forge
     libxcb                    1.13              h7f98852_1003    conda-forge
     libxml2                   2.9.12               h72842e0_0    conda-forge
     llvmlite                  0.36.0           py38h4630a5e_0    conda-forge
     locket                    0.2.0                      py_2    conda-forge
     lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
     markupsafe                2.0.1            py38h497a2fe_0    conda-forge
     morpheus                  0+unknown                pypi_0    pypi
     msgpack-python            1.0.2            py38h1fd1430_1    conda-forge
     nccl                      2.10.3.1             hdc17891_0    conda-forge
     ncurses                   6.2                  h58526e2_4    conda-forge
     networkx                  2.6.2                    pypi_0    pypi
     numba                     0.53.1           py38h8b71fd7_1    conda-forge
     numpy                     1.21.1           py38h9894fe3_0    conda-forge
     numpydoc                  1.1.0                      py_1    conda-forge
     nvidia-cublas             11.5.1.101               pypi_0    pypi
     nvidia-cuda-nvrtc         11.1.105                 pypi_0    pypi
     nvidia-cuda-runtime       11.3.58                  pypi_0    pypi
     nvidia-cudnn              8.2.0.51                 pypi_0    pypi
     nvidia-pyindex            1.0.9                    pypi_0    pypi
     nvidia-tensorrt           7.2.2.3                  pypi_0    pypi
     nvtx                      0.2.3            py38h497a2fe_0    conda-forge
     olefile                   0.46               pyh9f0ad1d_1    conda-forge
     openjpeg                  2.4.0                hb52868f_1    conda-forge
     openssl                   1.1.1k               h7f98852_0    conda-forge
     orc                       1.6.9                h58a87f1_0    conda-forge
     packaging                 21.0               pyhd8ed1ab_0    conda-forge
     pandas                    1.2.5            py38h1abd341_0    conda-forge
     pango                     1.48.7               hb8ff022_0    conda-forge
     parquet-cpp               1.5.1                         1    conda-forge
     partd                     1.2.0              pyhd8ed1ab_0    conda-forge
     pcre                      8.45                 h9c3ff4c_0    conda-forge
     pillow                    8.3.1            py38h8e6f84c_0    conda-forge
     pip                       21.2.2             pyhd8ed1ab_0    conda-forge
     pixman                    0.40.0               h36c2ea0_0    conda-forge
     protobuf                  3.16.0           py38h709712a_0    conda-forge
     psutil                    5.8.0            py38h497a2fe_1    conda-forge
     pthread-stubs             0.4               h36c2ea0_1001    conda-forge
     pyarrow                   1.0.1           py38hb53058b_44_cuda    conda-forge
     pycparser                 2.20               pyh9f0ad1d_2    conda-forge
     pydot                     1.4.2            py38h578d9bd_0    conda-forge
     pygments                  2.9.0              pyhd8ed1ab_0    conda-forge
     pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
     pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
     pyrsistent                0.17.3           py38h497a2fe_2    conda-forge
     pysocks                   1.7.1            py38h578d9bd_3    conda-forge
     python                    3.8.10          h49503c6_1_cpython    conda-forge
     python-confluent-kafka    1.5.0            py38h1e0a361_0    conda-forge
     python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
     python-dotenv             0.19.0             pyhd8ed1ab_0    conda-forge
     python-graphviz           0.17               pyhaef67bd_0    conda-forge
     python-rapidjson          1.4                      pypi_0    pypi
     python_abi                3.8                      2_cp38    conda-forge
     pytz                      2021.1             pyhd8ed1ab_0    conda-forge
     pyyaml                    5.4.1            py38h497a2fe_0    conda-forge
     re2                       2021.06.01           h9c3ff4c_0    conda-forge
     readline                  8.1                  h46c0cb4_0    conda-forge
     requests                  2.26.0             pyhd8ed1ab_0    conda-forge
     rmm                       21.06.00        cuda_11.2_py38_gee432a0_0    rapidsai
     s2n                       1.0.10               h9b69904_0    conda-forge
     scipy                     1.7.0            py38h7b17777_1    conda-forge
     setuptools                49.6.0           py38h578d9bd_3    conda-forge
     shellingham               1.4.0                    pypi_0    pypi
     six                       1.16.0             pyh6c4a22f_0    conda-forge
     snappy                    1.1.8                he1b5a44_3    conda-forge
     snowballstemmer           2.1.0              pyhd8ed1ab_0    conda-forge
     sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
     spdlog                    1.9.1                h4bd325d_0    conda-forge
     sphinx                    4.1.2              pyh6c4a22f_1    conda-forge
     sphinx_rtd_theme          0.5.2              pyhd8ed1ab_1    conda-forge
     sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
     sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
     sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_0    conda-forge
     sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
     sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
     sphinxcontrib-serializinghtml 1.1.5              pyhd8ed1ab_0    conda-forge
     sqlite                    3.36.0               h9cd32fc_0    conda-forge
     streamz                   0.6.2              pyh44b312d_0    conda-forge
     tblib                     1.7.0              pyhd8ed1ab_0    conda-forge
     text-unidecode            1.3                        py_0    conda-forge
     texttable                 1.6.4              pyhd8ed1ab_0    conda-forge
     tk                        8.6.10               h21135ba_1    conda-forge
     toolz                     0.11.1                     py_0    conda-forge
     tornado                   6.1              py38h497a2fe_1    conda-forge
     tqdm                      4.62.0             pyhd8ed1ab_0    conda-forge
     treelite                  1.3.0            py38hd08a91b_0    conda-forge
     treelite-runtime          1.3.0                    pypi_0    pypi
     tritonclient              2.12.0                   pypi_0    pypi
     typing-utils              0.1.0                    pypi_0    pypi
     typing_extensions         3.10.0.0           pyha770c72_0    conda-forge
     ucx                       1.9.0+gcd9efd3       cuda11.2_0    rapidsai
     ucx-proc                  1.0.0                       gpu    rapidsai
     ucx-py                    0.20.0          py38_gcd9efd3_0    rapidsai
     urllib3                   1.26.6             pyhd8ed1ab_0    conda-forge
     websocket-client          0.57.0           py38h578d9bd_4    conda-forge
     wheel                     0.36.2             pyhd3deb0d_0    conda-forge
     xgboost                   1.4.2                    pypi_0    pypi
     xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
     xorg-libice               1.0.10               h7f98852_0    conda-forge
     xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
     xorg-libx11               1.7.2                h7f98852_0    conda-forge
     xorg-libxau               1.0.9                h7f98852_0    conda-forge
     xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
     xorg-libxext              1.3.4                h7f98852_1    conda-forge
     xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
     xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
     xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
     xorg-xproto               7.0.31            h7f98852_1007    conda-forge
     xz                        5.2.5                h516909a_1    conda-forge
     yaml                      0.2.5                h516909a_0    conda-forge
     zict                      2.0.0                      py_0    conda-forge
     zipp                      3.5.0              pyhd8ed1ab_0    conda-forge
     zlib                      1.2.11            h516909a_1010    conda-forge
     zope-event                4.5.0                    pypi_0    pypi
     zope-interface            5.4.0                    pypi_0    pypi
     zstd                      1.5.0                ha95c52a_0    conda-forge

</pre></details>

Additional context

galipremsagar commented 3 years ago

@vuule This looks like a json reader/libcudf issue. Because I'm not able to repro this by creating a string column from cudf:

>>> import cudf
>>> cdf = cudf.read_json('sample.json', lines=True)
>>> import pandas as pd
>>> df = pd.read_json('sample.json', lines=True)
>>> df
   value                                data
0     16  thirty_chars_plus_two_newlines\n\n
1     19          more_data_with_newline\r\n
>>> cdf
   value                                data
0     16  thirty_chars_plus_two_newlines\n\n
1     19          more_data_with_newline\r\n
>>> cdf.data.str.len()
0    34
1    25
Name: data, dtype: int32
>>> s = cudf.Series(["thirty_chars_plus_two_newlines\n\n", "more_data_with_newline\r\n"])
>>> s
0    thirty_chars_plus_two_newlines\n\n
1            more_data_with_newline\r\n
dtype: object
>>> s[0]
'thirty_chars_plus_two_newlines\n\n'
>>> s.str.len()
0    32
1    24
dtype: int32
vuule commented 3 years ago

cudf is copying the strings from the file as-is. This is the same behavior as the CSV reader, and the Pandas CSV reader (by default). However, Pandas CSV reader replaces escaped newlines in strings when parameter escapechar is passed. Looks like Pandas JSON reader implicitly uses escapechar='\' and this is why the behavior differs from cudf. Because of the expected performance overhead, cudf CSV reader does not support the escapechar parameter. Need to evaluate whether we want to pursue parity with Pandas here.

github-actions[bot] commented 3 years ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] commented 2 years ago

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

GregoryKimball commented 1 year ago

It seems that this issue is addressed by the new JSON reader

j = '{"value": 16, "data": "thirty_chars_plus_two_newlines\n\n" }\n{"value": 19, "data": "more_data_with_newline\r\n"}'
df = cudf.read_json(j, lines=True, engine='cudf_experimental')
   value                                data
0     16  thirty_chars_plus_two_newlines\n\n
1     19          more_data_with_newline\r\n

I'll close this in favor of #11982