最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

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

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

2.用Python實(shí)現(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; ")

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

相關(guān)文章

  • 利用python實(shí)現(xiàn)冒泡排序算法實(shí)例代碼

    利用python實(shí)現(xiàn)冒泡排序算法實(shí)例代碼

    這篇文章主要給大家介紹了關(guān)于如何利用python實(shí)現(xiàn)冒泡排序算法的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用python具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • Python實(shí)現(xiàn)定時(shí)發(fā)送監(jiān)控郵件

    Python實(shí)現(xiàn)定時(shí)發(fā)送監(jiān)控郵件

    這篇文章主要為大家講解如何用python連接郵箱,實(shí)現(xiàn)自動(dòng)發(fā)送監(jiān)控郵件,文中的示例講解詳細(xì),對(duì)我們了解Python有一定的幫助,需要的可以參考一下
    2022-01-01
  • 如何使用Python實(shí)現(xiàn)名片管理系統(tǒng)

    如何使用Python實(shí)現(xiàn)名片管理系統(tǒng)

    這篇文章主要介紹了如何使用Python實(shí)現(xiàn)名片管理系統(tǒng),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下,希望對(duì)你的學(xué)習(xí)又是幫助
    2022-08-08
  • Python+Matplotlib+LaTeX玩轉(zhuǎn)數(shù)學(xué)公式

    Python+Matplotlib+LaTeX玩轉(zhuǎn)數(shù)學(xué)公式

    這篇文章主要為大家介紹了如何在Matplotlib中使用LaTeX?公式和符號(hào)以及Python如何生成LaTeX數(shù)學(xué)公式。文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2022-02-02
  • 最新評(píng)論

    吴桥县| 林口县| 丹棱县| 天等县| 梓潼县| 化隆| 克山县| 河池市| 宜宾市| 湘潭市| 瑞金市| 秦皇岛市| 婺源县| 昌黎县| 武威市| 手游| 德格县| 雅安市| 杭州市| 夏邑县| 中西区| 曲阜市| 柘荣县| 天祝| 宁都县| 张掖市| 涿鹿县| 韶山市| 刚察县| 北京市| 永康市| 佛坪县| 蛟河市| 新密市| 灌阳县| 内丘县| 翼城县| 邹平县| 武宁县| 肥西县| 夏邑县|