Import of japandas with pandas 1.0 and above

It seems that an error occurs when using japandas in an environment of pandas 1.0 or higher. The implementation of the solution to this problem is publicized on japandas github. However, although this PR was issued on June 23, 2020, it seems that it has been neglected. This time, I replaced lib/python3.8/site-packages/japandas with this PR code and it was successfully imported. Make a note of the procedure.

Version / environment

python 3.8.5 pandas 1.2.0 matplotlib 3.3.3 mplfinance 0.12.7a4 WSL2 Environment construction with venv We recommend working in a python virtual environment that can be broken.

error contents

When I import japandas, I get the following error.

----> 1 import japandas

~/env38/lib/python3.8/site-packages/japandas/__init__.py in <module>
      2 # coding: utf-8
      3 
----> 4 import japandas.core.strings                                                          # noqa
      5 import japandas.io.data                                                               # noqa
      6 from japandas.io.data import DataReader                                               # noqa

~/env38/lib/python3.8/site-packages/japandas/core/strings.py in <module>
      6 from unicodedata import normalize
      7 
----> 8 from pandas.compat import PY3, iteritems, u_safe
      9 import pandas.core.strings as strings
     10 

ImportError: cannot import name 'PY3' from 'pandas.compat' (/home/myname/env38/lib/python3.8/site-packages/pandas/compat/__init__.py)

https://github.com/sinhrks/japandas/pull/63 (Changes https://github.com/sinhrks/japandas/pull/63/files) PR seems to solve this problem. I didn't understand the detailed principle, but I think it's because the specifications of pandas have changed. I thought it was a painful part of the wrapper.

Work content

Clone the PR code to a suitable location. (Cloneed on January 5, 2020.)

cd ~/work
git clone -b si https://github.com/simaki/japandas.git

Delete japandas in site-package. (In my case, I created an environment with venv under/home/myname. Please read it in your own environment)

rm -rf /home/myname/env38/lib/python3.8/site-packages/japandas

I will copy it.

cp -r ~/work/japandas/japandas/ /home/myname/env38/lib/python3.8/site-packages

Check if the changes have been updated.

python:/home/myname/env38/lib/python3.8/site-packages/japandas/core/strings.py



#!/usr/bin/env python
# coding: utf-8

from __future__ import unicode_literals

from unicodedata import normalize

import pandas.core.strings as strings

Then, from pandas.compat import PY3, iteritems, u_safe is gone.

I got an error when I did import japandas here, so I installed matplotlib and mplfinance.

At this point, import japandas was completed.

In [9]: import japandas

Please let me know if there is a smarter way

At first I was wondering if I could install it locally and refer to that japandas in preference to site-package, but I couldn't do it well. I don't want to mess with lib too much.

Please let me know if there is a good way to do this or any other way. Thank you for reading.

Recommended Posts

Import of japandas with pandas 1.0 and above
Coexistence of Python2 and 3 with CircleCI (1.0)
I get an error with import pandas.
A little scrutiny of pandas 1.0 and dask
Load csv with pandas and play with Index
Read CSV and analyze with Pandas and Seaborn
Example of efficient data processing with PANDAS
Coexistence of Fcitx and Zoom ~ With Japanese localization ~
Implement "Data Visualization Design # 3" with pandas and matplotlib
Install pip and pandas with Ubuntu or VScode
Analyze Apache access logs with Pandas and Matplotlib
Interactively visualize data with TreasureData, Pandas and Jupyter.
Script to tweet with multiples of 3 and numbers with 3 !!
Calculation of technical indicators by TA-Lib and pandas
Header shifts in read_csv () and read_table () of Pandas
Implementation of TRIE tree with Python and LOUDS
I compared the moving average of IIR filter type with pandas and scipy
Download and import files with Splunk external python
Wavelet transform of images with PyWavelets and OpenCV
Aggregate VIP values of Smash Bros. with Pandas
Continuation of multi-platform development with Electron and Python
Example of reading and writing CSV with Python
Basic operation of Python Pandas Series and Dataframe (1)
I tried to compare the processing speed with dplyr of R and pandas of Python
Analysis of financial data by pandas and its visualization (2)
About import error of numpy and scipy in anaconda
Display embedded images of mp3 and flac with mutagen
Find the sum of unique values with pandas crosstab
Analysis of financial data by pandas and its visualization (1)
NameError (wrong entry of Import) and ImportError (no _init_.py)
Separation of Japanese surname and given name with BERT
Maximum likelihood estimation of mean and variance with TensorFlow
Specify upper directory / subdirectory with relative import of Python
Easy partial download of mp4 with python and youtube-dl!
Visualize the range of interpolation and extrapolation with python
Overview and tips of seaborn with statistical data visualization
How to extract null values and non-null values with pandas
How to output CSV of multi-line header with pandas
Create a batch of images and inflate with ImageDataGenerator
Extract the maximum value with pandas and change that value
Comparison of CoffeeScript with JavaScript, Python and Ruby grammar
Version control of Node, Ruby and Python with anyenv
[Memo] Load csv of s3 into pandas with boto3
Quickly visualize with Pandas
Processing datasets with pandas (1)
Bootstrap sampling with Pandas
Convert 202003 to 2020-03 with pandas
Processing datasets with pandas (2)
Merge datasets with pandas
jupyter and pandas installation
Basic operation of pandas
Learn Pandas with Cheminformatics
About MultiIndex of pandas
pandas index and reindex
Basic operation of Pandas
Data visualization with pandas
Data manipulation with Pandas!
pandas resample and rolling
Shuffle data with pandas
Pandas averaging and listing
Import tsv with Python