Skip to content

Instantly share code, notes, and snippets.

View koizumihiroo's full-sized avatar

KOIZUMI, Hiroo koizumihiroo

  • justInCase, Inc.
  • Tokyo
View GitHub Profile

pandas 1.0.0 (rc0) での pd.NA の特徴

update1 2020-01-25: bug っぽい挙動は bug だった旨を追加

2020-01-13 時点で pandas 1.0.0rc0 が公開されているが、大きな特徴の一つに missing value として pd.NA が導入される。この性質や使い方についてまとめる。

Disclaimer: pandas 1.0.0 rc0 での動作確認であり、将来的にも変更の可能性が十分ある。

検証環境 は最後に。

import collections
import random
import string
from typing import List
numbers: str = string.digits
lowers: str = string.ascii_lowercase
uppers: str = string.ascii_uppercase
"""
CAUTION:
The porpose of this script is just to translate original R script into Python script; there is
no guarantee of accuracy of contents.
Original Article:
CC BY 4.0:
Greatly appreciated the effort of the publishing as open source license.
https://www.eurosurveillance.org/content/10.2807/1560-7917.ES.2020.25.5.2000062
https://www.ncbi.nlm.nih.gov/pubmed/32046819
inline class Currency<T>(private val value: Double) {
operator fun plus(c2: Currency<T>): Currency<T> = Currency(value + c2.value)
operator fun minus(c2: Currency<T>): Currency<T> = Currency(value - c2.value)
operator fun times(c2: Currency<T>): Currency<T> = Currency(value * c2.value)
operator fun div(c2: Currency<T>): Currency<T> = Currency(value / c2.value)
operator fun unaryPlus(): Currency<T> = this
operator fun unaryMinus(): Currency<T> = Currency(-value)
fun toDouble(): Double = value
}