Skip to main content
japandas
========

.. image:: https://img.shields.io/pypi/v/japandas.svg
:target: https://pypi.python.org/pypi/japandas/
.. image:: https://readthedocs.org/projects/japandas/badge/?version=latest
:target: http://japandas.readthedocs.org/en/latest/
:alt: Latest Docs
.. image:: https://travis-ci.org/sinhrks/japandas.svg?branch=master
:target: https://travis-ci.org/sinhrks/japandas
.. image:: https://codecov.io/gh/sinhrks/japandas/branch/master/graph/badge.svg
:target: https://codecov.io/gh/sinhrks/japandas

Overview
~~~~~~~~

pandas Japanese extension.

pandas の日本語拡張。以下の機能を提供する。

- 日本語の日付のパース
- 日本の祝日カレンダーと、それを利用した営業日計算
- 文字列の全角/半角変換
- e-Stat からのデータの取得
- ローソク足チャート

**補足** このパッケージでは、"日本固有の機能であり本流に実装される可能性が低いもの", もしくは"それらに関係し本流に実装される可能性が低いもの" を実装 / メンテナンスする。


インストール
~~~~~~~~~~

.. code-block:: sh

pip install japandas

ドキュメント
~~~~~~~~~~

- 開発版: http://japandas.readthedocs.org/en/latest/
- リリース版: http://japandas.readthedocs.org/en/stable/

機能概要
~~~~~~~

日本語の日付のパース
,,,,,,,,,,,,,,,,,

.. code-block:: python

>>> import japandas as jpd
>>> jpd.to_datetime('2014年11月30日')
Timestamp('2014-11-30 00:00:00')

>>> jpd.to_datetime(['2014年11月30日13時25分', '2014年11月30日14時38分'])
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-11-30 13:25:00, 2014-11-30 14:38:00]
Length: 2, Freq: None, Timezone: None

>>> jpd.date_range(start=u'2013年12月01日', end=u'2014年12月01日', freq='D')
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-12-01, ..., 2014-12-01]
Length: 366, Freq: D, Timezone: None


日本の祝日カレンダーと、それを利用した営業日計算
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

.. code-block:: python

>>> import pandas as pd
>>> import datetime

>>> calendar = jpd.JapaneseHolidayCalendar()
>>> cday = pd.offsets.CDay(calendar=calendar)

>>> datetime.datetime(2014, 4, 28) + cday
# 4/29は祝日(昭和の日)
Timestamp('2014-04-30 00:00:00')

>>> datetime.datetime(2014, 4, 28) - cday
# 4/26は土曜日, 4/27は日曜日
Timestamp('2014-04-25 00:00:00')

>>> datetime.datetime(2014, 5, 3) + cday
# 5/4は日曜日, 5/5は祝日(こどもの日), 5/6は祝日(みどりの日/振替休日)
Timestamp('2014-05-07 00:00:00')

>>> datetime.datetime(2014, 5, 3) - cday
# 5/3は土曜日
Timestamp('2014-05-02 00:00:00')

# 適当なデータを作成
>>> df = pd.DataFrame(np.random.randn(10, 3),
... index=jpd.date_range(u'2014年5月1日', u'2014年5月10日', freq='D'))
>>> df
0 1 2
2014-05-01 0.762453 -1.418762 -0.150073
2014-05-02 0.966500 -0.473888 0.272871
2014-05-03 0.473370 -1.282504 0.380449
2014-05-04 0.215411 0.220587 -1.088699
2014-05-05 0.286348 -1.069165 -1.471871
2014-05-06 -0.665438 -0.402046 -1.008051
2014-05-07 1.173935 2.080087 -2.279285
2014-05-08 -0.957195 0.746798 0.092214
2014-05-09 -0.259276 -0.775489 0.572525
2014-05-10 -0.910188 0.294136 0.020730

>>> cday = pd.offsets.CDay(calendar=calendar)
>>> indexer = jpd.date_range(u'2014年5月1日', u'2014年5月10日', freq=cday)

# カレンダー上 営業日のレコードを抽出
>>> df.ix[indexer]
0 1 2
2014-05-01 0.762453 -1.418762 -0.150073
2014-05-02 0.966500 -0.473888 0.272871
2014-05-07 1.173935 2.080087 -2.279285
2014-05-08 -0.957195 0.746798 0.092214
2014-05-09 -0.259276 -0.775489 0.572525


全角/半角変換
,,,,,,,,,,,

.. code-block:: python

>>> s = pd.Series([u'アイウエオ', u'ABC01', u'DE345'])
>>> z = s.str.h2z()
>>> z
0 アイウエオ
1 ABC01
2 DE345
dtype: object

>>> z.str.z2h()
0 アイウエオ
1 ABC01
2 DE345
dtype: object

e-Stat からの統計情報取得
,,,,,,,,,,,,,,,,,,,,,,,

.. code-block:: python

>>> key = "your application id"
>>> df = jpd.DataReader("0000030001", 'estat', appid=key)
>>> df.head()
value 全国都道府県030001 全域・集中の別030002 年齢5歳階級A030002 男女A030001
時間軸(年次)
1980年 117060396 全国 全域 総数 男女総数
1980年 89187409 全国市部 全域 総数 男女総数
1980年 27872987 全国郡部 全域 総数 男女総数
1980年 5575989 北海道 全域 総数 男女総数
1980年 1523907 青森県 全域 総数 男女総数


ローソク足チャート
,,,,,,,,,,,,,,,,,

.. code-block:: python

>>> df.plot(kind='ohlc')
チャート省略


License
~~~~~~~

BSD.

日本の祝日データソースとして以下を利用。

- `komagata/holiday_jp <https://github.com/komagata/holiday_jp>`_

Copyright (c) 2009 Masaki Komagata. See `LICENSE <https://github.com/komagata/holiday_jp/blob/master/LICENSE>`_ for details.

- `holiday_jp <https://github.com/holiday-jp/holiday_jp>`_

MIT.


Metadata

Release files for japandas 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for japandas 0.5.1
File Size Uploaded Provenance
japandas-0.5.1.tar.gz 57.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for japandas 0.5.1
File Interpreter ABI Platform
japandas-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 118.5 kB

Release files / japandas-0.5.1.tar.gz

Download URL japandas-0.5.1.tar.gz
Size 57.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8260517d9ba0cff7de1043d01df98e6c196129937b21c2619a760ddab9efd005
BLAKE2b-256 checksum
How to use checksums
6c0bc5ae46645c489cb3e4d53f4cfde6a197d1e4bc2680d7f321b99a8b9da10b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6

Release files / japandas-0.5.1-py3-none-any.whl

Download URL japandas-0.5.1-py3-none-any.whl
Size 60.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb86a8dc9b83f0cebe72613c5922bf10d80accbad40d9c190e298fc3286dd2a5
BLAKE2b-256 checksum
How to use checksums
eb98f389a19e1168abbe4f78ba71b653a21b976ab9e82bf45f7399458f385392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6

Security for japandas 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page