neovimで全角記号の表示崩れを解消する
neovimでLazyVimを使い始めたけど、全角記号の表示が崩れます。
ambiwidth を double に設定すれば解決できるはずですが、LazyVimの listchars 等の設定と競合してしまい、エラーになって設定できませんでした。
そんなときに、下記のプラグインを見つけました。
このプラグインをインストールするには、~/AppData/Local/nvim/lua/custom.lua などの設定ファイルに以下の内容を追加します。
return {
{
"delphinus/cellwidths.nvim",
config = function()
require("cellwidths").setup({ name = "default" })
end,
},
}
AngularとionicのプロジェクトのTailwind CSSをV4に挙げたときのメモ
Pandasでグループごとに連番を付与する方法
題名のことをやりたくて下記を参考にして実装したところ、現在ではDataFrameGroupBy.grouperがdeprecatedとの警告が表示されました。
警告内容
FutureWarning: DataFrameGroupBy.grouper is deprecated and will be removed in a future version of pandas. ids = df.groupby(["ID"]).grouper.group_info[0]
調べたところ、同様のことはngroupを使えばできるようでした。
ngroupを使ったソースコードは下記のとおり。
import pandas as pd df = pd.DataFrame({'ID': [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4], '日': ['4/3', '4/5', '4/1', '4/1', '5/30', '5/5', '5/5', '5/5', '6/7', '5/3', '5/3', '6/7'], '店舗': ['A', 'B', 'A', 'A', 'C', 'A', 'B', 'B', 'B', 'C', 'D', 'A'], 'カウント': ['1', '2', '1', '1', '2', '1', '2', '2', '3', '1', '2', '3']}) # ids = df.groupby(["ID"]).grouper.group_info[0] # 警告が表示される # comb = df.groupby(["ID", "日", "店舗"]).grouper.group_info[0] ids = df.groupby(["ID"]).ngroup() comb = df.groupby(["ID", "日", "店舗"]).ngroup() count = [] nth = 0 for i, c in enumerate(comb): if i == 0 or ids[i] != ids[i - 1]: nth = 1 elif c != comb[i - 1]: nth += 1 count += [nth] df["カウント"] = count print(df)
出力結果
ID 日 店舗 カウント 0 1 4/3 A 1 1 1 4/5 B 2 2 2 4/1 A 1 3 2 4/1 A 1 4 2 5/30 C 2 5 3 5/5 A 1 6 3 5/5 B 2 7 3 5/5 B 2 8 3 6/7 B 3 9 4 5/3 C 1 10 4 5/3 D 2 11 4 6/7 A 3
Go言語でChunk処理
SnakeCaseとCamelCaseを変換する
Vimを利用する場合
下記のライブラリを利用させてもらいました。
Plug "nicwest/vim-camelsnek"
:Snek " converts to snake_case ('foo bar' -> 'foo_bar')
:Camel " converts to CamelCase ('foo bar' -> 'FooBar')
:CamelB " converts to camelbackCase ('foo bar' -> 'fooBar')
:Kebab " converts to kebab-case ('foo bar' -> 'foo-bar')
:Screm " converts to SCREAMING_SNAKE_CASE ('foo bar' -> 'FOO_BAR')
Jetbrain系IDEを利用する場合
下記の記事を参考に、CamelCase というライブラリを利用することでできました。 mokky14.hatenablog.com
Shift+Alt+u で切り替えができるようになります。