問題タブ [pandas-loc]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
pandas - Pandas - apply loc 操作から返されたデータフレームの対角値を平坦化します
2 つのデータフレームがあります。各行について、一致するものを検索し、対応する値を取得df
したいと考えています。epoch_minute - lag
average_hc
この for ループはトリックを行います。
この正しい Series を生成しますlag
。
操作と同じロジックを試すとapply
:
私が期待していたシリーズの代わりに、この正しく評価されたが間違った形状のデータフレームが生成されます。
ナンを削除するか、によって返されるデータフレームを平坦化してapply
、対角値のシリーズにする方法を教えてください。
python - Setting dataframe columns returns persisting "value is trying to be set on a copy of a slice" warning
I am aware of the implications of chaining get/set and the fact that it may mean I am working on a copy. If I use loc()
, I still get a warning (without the loc part, but still a warning).
I have a DF with a column 'A' which is a date but with a type string.
I am converting the string object to date (at all rows):
I then turn it back to string formatted in a particular way. I know I am taking a detour here but I want to experiment:
I then split the column to multiple columns accordingly:
All this seems to be working, but I get the "A value is trying to be set on a copy of a slice from a DataFrame. Try to use loc..." warning three times.
I have also tried to create new columns on the LH of the assignments, so as not to try get and set the same columns at the same time. The warning persists.
What is the right way to do this? I want to set the original dataframe.