日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pandas数据分析选则接近数值的最接优方案

發布時間:2024/7/5 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pandas数据分析选则接近数值的最接优方案 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import numpy as np import pandas as pd# pandas數據分析選則接近數值的最接優方案# 1.準備數據 CHILD_TABLE = (720, 750) CHIDL_STOOL = (300, 350) CHILD_PLAY_LEN = (300, 400) CHILD_TENT = (1100, 1300) # 2.遍歷循環,添加到列表中 sum_length_lst = [] play_lst = [] table_lst = [] stool_lst = [] tent_lst = [] for play_b in CHILD_PLAY_LEN:for table_b in CHILD_TABLE:for stool_b in CHIDL_STOOL:for tent_b in CHILD_TENT:tent_lst.append(tent_b)play_lst.append(play_b)table_lst.append(table_b)stool_lst.append(stool_b)# 3.計算各個之和,生成列表sum_len = play_b + table_b + stool_b + tent_bsum_length_lst.append(sum_len) # 4.添加到字典 pd_dict = {"sum_len": sum_length_lst,"play_len": play_lst,"table_len": table_lst,"stool_len": stool_lst,"tent_len": tent_lst } # 5.生成列表數據、排序 df = pd.DataFrame(pd_dict) df = df.sort_values(by='sum_len') print(df) 自動生成列表并排序:


# 6.根據判斷距離尋找列表接近數值的表方案 dis = 2700 nearst_df = df.loc[df.sum_len <= dis ] nearst_df = nearst_df.ix[nearst_df.sum_len.idxmax] print(nearst_df)

結果顯示如下:


總結

以上是生活随笔為你收集整理的pandas数据分析选则接近数值的最接优方案的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。