河南住房和城乡建设厅网站主页,wordpress站内搜索次数,那个网站可以免费做风面,东莞常平限电通知2021用Python实现数据透视表、音频文件格式转换
1.用Python实现数据透视表
import pandas as pdif __name__ __main__:# df pd.read_excel(广告-资源位变现效率监测看板-1.xlsx, sheet_name各业务在该资源位的明细数据)df pd.read_excel(填充率分析-Q3.xlsx, sheet_name库存底…用Python实现数据透视表、音频文件格式转换
1.用Python实现数据透视表
import pandas as pdif __name__ __main__:# df pd.read_excel(广告-资源位变现效率监测看板-1.xlsx, sheet_name各业务在该资源位的明细数据)df pd.read_excel(填充率分析-Q3.xlsx, sheet_name库存底表)df df.loc[df[dt].str.startswith(2023-09-21)]# df df.loc[df[dt].str.startswith(2023-09-)]df df.loc[df[资源位] 亮屏贴片]# df df.loc[df[业务类型] 品牌广告]total df[库存].sum()print(total)2.用Python实现音频文件格式转换
from pydub import AudioSegment
import osdef add_path():path os.environ.get(PATH)path path[:-1]# new_path C:\\Program Files\\gs\\gs10.01.2\\bin;.new_path C:\\myPC\\tools\\ffmpeg\\bin;.updated_path path new_pathos.environ[PATH] updated_pathdef convert_m4a_to_wav(input_file, output_file):audio AudioSegment.from_file(input_file, formatm4a)audio.export(output_file, formatwav, parameters[-ar, 16000])print(fDuration of {output_file}: {audio.duration_seconds} seconds)return audio.duration_secondsif __name__ __main__:add_path()directory ./M4A/files os.listdir(directory)total_seconds 0.0for file in files:print(Processing , file)file file.replace(.m4a, )total_seconds total_seconds convert_m4a_to_wav(./M4A/ file .m4a, ./WAV/ file .WAV)total_minutes total_seconds / 60.0total_hours total_minutes / 60.0print(Total: str(total_seconds) sec; )print(Total: str(total_minutes) min; )print(Total: str(total_hours) hour; )