This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def melt_columns(df: pd.DataFrame, sep: str="_") -> pd.DataFrame: | |
"""与えられたデータフレームの列がMultiIndexの場合にそれを非階層なIndexにして返す. | |
Arguments: | |
df (pd.DataFrame) : 列を非階層にしたいデータフレーム. | |
sep (str) : 新たな列名を作るときにセパレーターとして使われる文字列. デフォルトでは"_". | |
Return: | |
pd.DataFrame : 列名が非階層なIndexとなっているデータフレーム | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.10 | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir pandas==1.4.3 pyarrow==8.0.0 fastparquet==0.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def coalesce(df: pd.DataFrame, *args) -> pd.Series: | |
return df[list(args)].bfill(axis=1).iloc[:, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Pkg | |
function add_if_not_found(packages) | |
installed = [dep.name for (_, dep) in Pkg.dependencies() if dep.is_direct_dep] | |
targets = [] | |
for pkg in packages | |
pkg in installed || push!(pkg, targets) | |
end | |
isempty(targets) || Pkg.add(targets) | |
end |
OlderNewer