pythonで 日時の計算: timedelta
datetime モジュール使う。
ネタ元
python pandasで前日比(差分)計算
diff() / pct_change()を使う
df_webdata['前日との差分']=df_webdata['Close'].diff()
%にするなら100乗算
df_webdata['前日との差分率']=df_webdata['Close'].pct_change()*100
.NET5でShift-JISを扱う
Encoding.GetEncoding("Shift_JIS");と書いたら例外がでた。
Unhandled exception. System.ArgumentException: 'Shift_JIS' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
もう Shift_JISはデフォルト対応ではないみたい。
以下一行を追加すればOK
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
pythonをexe化する PyInstaller の使い方
pipenvで仮想環境構築
pipenv shellでシェルを開き
必要なライブラリをインストール
PyInstallerをインストールして
pyinstaller test.py --onefile
という感じでexe化
windows環境用。python配布に便利なPython embeddable package
exe化するのもいいけど、こっちのほうが利点が多いらしい
c++ 2byte文字(日本語)ありのパスだとsystem()では実行失敗する
ハマった
ShellExecuteEx()でlpDirectoryにフォルダ指定して実行させるとよい。
ただし、lpFileやlpParametersの中にも日本語文字は入らないようにすること。
Excelで連続した数の計算
連敗や連勝などの数を計算するのに使える
ネタ元
pythonでキーボードからの入力待ち
var = input("Please input variable : ")