mmw Demo Data Structure v0.1:
#ADCsamples is set in the profileCfg line of the cfg file ;
#RangeBins = number of ADC samples rounded up(向上取整) to the nearest power of 2
profile.cfg : profileCfg 0 77 372 7 114.29 0 0 35 1 240 2257 0 0 30 ;
import math
# number of ADC samples
num_adc_samples = 240
# calculate RangeBins
range_bins = int(math.pow(2, math.ceil(math.log2(num_adc_samples))))
"""math.pow(2, 3) = 2**3 #2的3次方
2** math.ceil(math.log2(num_adc_samples))
#這樣也可以 #2**8=256
使用math模塊中的pow、ceil和log2函數來計算RangeBins。
首先,我們使用math.log2函數來計算num_adc_samples的對數。
然後,我們使用math.ceil函數將其向上取整到最接近的整數。
最後,我們使用math.pow函數計算2的幾次方,以得到最終的RangeBins值。
"""
print("RangeBins:", range_bins)

推薦hahow線上學習python: https://igrape.net/30afN


![Python: 如何用 pandas.DataFrame.apply 讓DataFrame增加新的一欄 ; df[“mean”] = df.apply( np.mean, axis=1) ; DataFrame.apply(func, axis=0, raw=False, result_type=None, args=(), **kwargs) Python: 如何用 pandas.DataFrame.apply 讓DataFrame增加新的一欄 ; df[“mean”] = df.apply( np.mean, axis=1) ; DataFrame.apply(func, axis=0, raw=False, result_type=None, args=(), **kwargs)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20230519084320_22.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




![Python: pandas.read_excel(r”路徑\檔名.副檔名”, header = None), 自動加上0,1…的欄標籤, DataFrame如何取某一直欄或橫列? 如何用 .iloc[bool_list] 取出判斷式為真的那一列? bool_list = list( df[0] == 0 ) ; bool_list = list(df[0].isin([0])) ; DataFrame如何顯示完整的資料? pandas.set_option ( “display.max_rows”, None) Python: pandas.read_excel(r”路徑\檔名.副檔名”, header = None), 自動加上0,1…的欄標籤, DataFrame如何取某一直欄或橫列? 如何用 .iloc[bool_list] 取出判斷式為真的那一列? bool_list = list( df[0] == 0 ) ; bool_list = list(df[0].isin([0])) ; DataFrame如何顯示完整的資料? pandas.set_option ( “display.max_rows”, None)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/11/20221128164005_44.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: pandas.DataFrame 如何對某些欄做格式化字串? apply(); applymap() ; map() 的差別? df[‘Salary’] = df[‘Salary’].map( ‘${:,.2f}’ .format) Python: pandas.DataFrame 如何對某些欄做格式化字串? apply(); applymap() ; map() 的差別? df[‘Salary’] = df[‘Salary’].map( ‘${:,.2f}’ .format)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20230527091636_49.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言