iT邦幫忙

1

pandas isin 順序問題

我利用第一個dataframe用isin去抓我食譜食材的資料,但不管怎麼樣isin好像會直接由小到大排序?
https://ithelp.ithome.com.tw/upload/images/20210512/201374208wPbfU3lsy.jpg

https://ithelp.ithome.com.tw/upload/images/20210512/20137420X4Ppgju0ti.jpg

我希望顺序是第一張dataframe的Dishes_id的排序,不知道有沒有什麼好方法

查詢你的原生語言中, 陣列或物件相關的原生函數
排序應該基本都有
參考看看
https://officeguide.cc/python-sort-sorted-tutorial-examples/
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
納貝
iT邦新手 1 級 ‧ 2021-05-14 11:29:22
最佳解答

不要用isin
用這個

Lawrence_recommendation =feedALL_df.set_index('dishes_id').loc[reommended_food['Dishes_id']].reset_index()
納貝 iT邦新手 1 級 ‧ 2021-06-03 11:37:00 檢舉

zxcjason234
選我正解/images/emoticon/emoticon01.gif

我後來自己完成了,謝謝幫助

我要發表回答

立即登入回答