欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何使用Python實現(xiàn)數(shù)據(jù)透視表、音頻文件格式轉(zhuǎn)換

 更新時間:2023年10月13日 09:20:51   作者:穿越前列線打造非凡yt  
這篇文章主要介紹了用Python實現(xiàn)數(shù)據(jù)透視表、音頻文件格式轉(zhuǎn)換,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

用Python實現(xiàn)數(shù)據(jù)透視表、音頻文件格式轉(zhuǎn)換

1.用Python實現(xiàn)數(shù)據(jù)透視表

import pandas as pd
if __name__ == '__main__':
    # df = pd.read_excel('廣告-資源位變現(xiàn)效率監(jiān)測看板-1.xlsx', sheet_name='各業(yè)務在該資源位的明細數(shù)據(jù)')
    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['業(yè)務類型'] == '品牌廣告']
    total = df['庫存'].sum()
    print(total)

2.用Python實現(xiàn)音頻文件格式轉(zhuǎn)換

from pydub import AudioSegment
import os
def 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_path
    os.environ['PATH'] = updated_path
def convert_m4a_to_wav(input_file, output_file):
    audio = AudioSegment.from_file(input_file, format="m4a")
    audio.export(output_file, format="wav", parameters=["-ar", "16000"])
    print(f"Duration of {output_file}: {audio.duration_seconds} seconds")
    return audio.duration_seconds
if __name__ == '__main__':
    add_path()
    directory = "./M4A/"
    files = os.listdir(directory)
    total_seconds = 0.0
    for 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.0
    total_hours = total_minutes / 60.0
    print("Total: " + str(total_seconds) + " sec; ")
    print("Total: " + str(total_minutes) + " min; ")
    print("Total: " + str(total_hours) + " hour; ")

到此這篇關于用Python實現(xiàn)數(shù)據(jù)透視表、音頻文件格式轉(zhuǎn)換的文章就介紹到這了,更多相關Python數(shù)據(jù)透視表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論