Rust

Rustでプログラミング言語を作る

元ネタは『WEB+DB PRESS Vol.125』の ディレクトリ構成は src/toys の下に各種 rs ファイルと pest ファイルを置いている。四則演算の AST とインタプリタを作る。operator.rs#[derive(D...
Rust

Rustで二分探索法 (0)

以前読んだ『アルゴリズムとデータ構造』を Rust で実装してみたい。本の実装は C++。まずは二分探索を実装してみる。必要なら以下の dependencies を追加。proconio = "0.4.3"lib.rs(二分探索の本体)pu...
Python

Pythonでdictをarrayに変換する (DictVectorizer)

Python で dict を numpy の array に変換するには、scikit-learn の DictVectorizer を使うとよい(試した scikit-learn の version: 1.0.1)import nump...
Python

PyO3でPythonからRustを使う(2: 並列処理)

cargo new --lib word-countCargo.toml[package]name = "word-count"version = "0.1.0"edition = "2018"# See more keys and the...
プログラミング

PyO3でPythonからRustを使う(1.1)

前回の続きというかやり直しライブラリを作るcargo new --lib pyo3testCarto.toml に以下を追加[lib]name = "libname"crate-type = ["cdylib"][dependencies....
Python

PyO3でPythonからRustを使う

PyO3を試したversionPython: 3.8.10Rust: 1.55.0OS は Windowsライブラリを作るcargo new --lib addarrayCarto.toml に と を追加[package]name = "...
Python

DataFrameの手動ソートのトリック

df.col = df.col.astype("category")df.col.cat.set_categories(sorted_list, inplace=True)df = df.sort_values(["col"]).reset...
統計学

Pythonでサンプルサイズと検出力

ABテストで使うやつfrom __future__ import annotationsimport mathfrom typing import Tupleimport pandas as pdfrom scipy.stats impor...
Python

matplotlibの日本語化

import matplotlibfrom matplotlib import font_managerfont_manager.fontManager.addfont("path/to/ipaexg.ttf")matplotlib.rc(...
Python

pythonでExcel作成

# 桁区切りのカンマありの整数format_int = {'num_format': '#,##0', 'align': 'right'}# 小数点以下2桁format_flt = {'num_format': '#,##0.00', 'a...