当前位置: 首页 > news >正文

用Python实现数据透视表、音频文件格式转换

用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, format="m4a")audio.export(output_file, format="wav", parameters=["-ar", "16000"])print(f"Duration 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; ")

http://www.lryc.cn/news/189631.html

相关文章:

  • java枚举中写抽象方法
  • 麒麟操作系统提示“默认密钥环已上锁”的解决办法
  • 云原生周刊:Docker 推出 Docker Debug | 2023.10.9
  • 设计模式 - 行为型模式考点篇:迭代器模式(概述 | 案例实现 | 优缺点 | 使用场景)
  • Spark任务优化分析
  • 最新数据库流行度最新排名(每月更新)
  • Python:如何在一个月内学会爬取大规模数据
  • K8S云计算系列-(4)
  • 【Mybatis源码】IDEA中Mybatis源码环境搭建
  • VUE如何使得大屏自适应的几种方法?
  • API接口安全运营研究(内附官方开发平台api接口接入方式)
  • 信钰证券:股票交易费用计算方法?
  • 通过js获取用户网络ip地址
  • 微信小程序wxml使用过滤器
  • 内网渗透面试问题
  • Go语言函数进阶:值传递、引用传递、函数式编程
  • 数据结构 堆——详细动画图解,形象理解
  • 使用pymodbus进行modbus-TCP通信
  • 2. redis常见数据类型
  • 多测师肖sir_高级金牌讲师_python之结构语句005
  • 用3-8译码器实现全减器
  • 招投标系统简介 企业电子招投标采购系统源码之电子招投标系统 —降低企业采购成本
  • Linux Centos7 下使用yum安装的nginx平滑升级
  • C/S架构学习之多线程实现TCP并发服务器
  • iPhone手机记笔记工具选择用哪个
  • MyBatis动态SQL(if、choose、when和otherwise)标签
  • idea将jar包deploy到本地仓库
  • 麻省理工学院与Meta AI共同开发StreamingLLM框架,实现语言模型无限处理长度
  • 记录 K8S 挂了的解决经过
  • Flink---11、状态管理(按键分区状态(值状态、列表状态、Map状态、归约状态、聚合状态)算子状态(列表状态、广播状态))