随笔分类 -  Python

上一页 1 2 3 4 5 6 ··· 8 下一页
Python
摘要:import sys from PySide6 import QtCore,QtWidgets from PySide6.QtCore import QAbstractTableModel,Qt from PySide6.QtWidgets import QApplication, QMainWin 阅读全文
posted @ 2024-11-29 21:37 华小电 阅读(623) 评论(0) 推荐(0)
摘要:Moviepy可以进行视频剪辑、合并、转码以及添加各种效果等操作。 读取文件 from moviepy.editor import mp clip = mp.VideoFileClip('video.mp4') print(clip.size) # 获取分辨率 print(clip.duration 阅读全文
posted @ 2024-10-07 09:49 华小电 阅读(197) 评论(0) 推荐(0)
摘要:要获取两个 DataFrame 中某两列相同的项,可以使用 pandas 的 merge 方法或 isin 方法。以下是两种方法的示例。 方法 1: 使用 merge merge 方法可以用来根据多个列将两个 DataFrame 合并。通过设置 how='inner',可以得到两个 DataFram 阅读全文
posted @ 2024-09-24 08:35 华小电 阅读(431) 评论(0) 推荐(0)
摘要:class MinMaxScaler: def __init__(self, feature_range=(0, 1),max_val =None,min_val = None): self.feature_range = feature_range self.data_min_ = min_val 阅读全文
posted @ 2024-09-17 22:13 华小电 阅读(87) 评论(0) 推荐(0)
摘要:数据文件:test.csv df = pd.read_csv('test.csv') print(df) a b c d 0 1 2 3 4 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 6 7 8 9 10 7 2 3 4 5 8 3 4 5 阅读全文
posted @ 2024-08-25 19:29 华小电 阅读(51) 评论(0) 推荐(0)
摘要:import sys from PySide6.QtWidgets import QApplication, QPushButton,QWidget class window_1(QWidget): def __init__(self): super().__init__() self.setWin 阅读全文
posted @ 2024-08-18 15:52 华小电 阅读(104) 评论(0) 推荐(0)
摘要:torch.utils.data是PyTorch中用于数据加载和预处理的模块。通常结合使用其中的Dataset和DataLoader两个类来加载和处理数据。 Dataset torch.utils.data.Dataset是一个抽象类,用于表示数据集。 需要用户自己实现两个方法:__len__和__ 阅读全文
posted @ 2024-08-02 21:23 华小电 阅读(230) 评论(0) 推荐(0)
摘要:通过Dataframe.info() 发现数据类型有object、float64,需要把object 转换成 float64, 需要使用pd.to_numeric()函数来把列转换为数值类型,如果转换失败,可以设置参数errors='coerce'使得失败的转换结果为NaN。 for col in 阅读全文
posted @ 2024-07-26 22:08 华小电 阅读(744) 评论(0) 推荐(0)
摘要:1、在 Python 中使用 pickle 模块的 dump 函数将字典保存到文件中 import pickle my_dict = { 'Apple': 4, 'Banana': 2, 'Orange': 6, 'Grapes': 11} # 保存文件 with open("myDictionar 阅读全文
posted @ 2024-07-26 09:18 华小电 阅读(1435) 评论(0) 推荐(0)
摘要:定义LSTM神经网络模型 class LSTM(nn.Module): """ Parameters: - input_size: 输入特征数 - hidden_size: 单个隐藏层的节点数 - output_size: 输出特征数 - num_layers: 隐藏层数 """ def __ini 阅读全文
posted @ 2024-07-22 09:14 华小电 阅读(30) 评论(0) 推荐(0)
摘要:1.*.pt文件 .pt文件保存的是模型的全部,在加载时可以直接赋值给新变量model = torch.load("filename.pt")。 具体操作: (1). 模型的保存 torch.save(model,"Path/filename.pt") (2). 模型的加载 model = torc 阅读全文
posted @ 2024-07-19 10:09 华小电 阅读(1298) 评论(0) 推荐(0)
摘要:1. 使用QUiloader加载 from PySide6.QtUiTools import QUiLoader from PySide6.QtWidgets import QApplication,QWidget import sys class ui_call(QWidget): def __i 阅读全文
posted @ 2024-07-16 09:44 华小电 阅读(232) 评论(0) 推荐(0)
摘要:A string is happy if every three consecutive characters are distinct. def check_if_string_is_happy1(input_str): check = [] for a,b,c in zip(input_str, 阅读全文
posted @ 2024-07-14 10:11 华小电 阅读(7) 评论(0) 推荐(0)
摘要:isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。 isinstance() 与 type() 区别: type() 不会认为子类是一种父类类型,不考虑继承关系。 isinstance() 会认为子类是一种父类类型,考虑继承关系。 如果要判断两个类型是否相同推荐使 阅读全文
posted @ 2024-07-14 09:13 华小电 阅读(40) 评论(0) 推荐(0)
摘要:Themes from qt_material import list_themes print(list_themes()) ['dark_amber.xml', 'dark_blue.xml', 'dark_cyan.xml', 'dark_lightgreen.xml', 'dark_medi 阅读全文
posted @ 2024-07-10 10:48 华小电 阅读(79) 评论(0) 推荐(0)
摘要:在Matplotlib中,如果你有一个时间序列数据,并且x轴上的时间标签太多导致它们重叠或难以阅读,你可以通过几种方法来减少显示的标签数量或调整它们的格式。以下是一些常用的方法: 使用plt.xticks()手动设置x轴标签: 你可以通过plt.xticks()手动设置你想显示的x轴标签的位置和文本 阅读全文
posted @ 2024-04-27 15:16 华小电 阅读(811) 评论(0) 推荐(0)
摘要:groupby是Pandas用于根据给定列中的不同值对数据点(即行)进行分组,分组后的数据可以计算生成组的聚合值。 agg 聚合操作 聚合操作是groupby后非常常见的操作,聚合操作可以用来求和、均值、最大值、最小值等. 函数 用途 函数 用途 min 最小值 max 最大值 sum 求和 mea 阅读全文
posted @ 2024-04-05 17:25 华小电 阅读(165) 评论(0) 推荐(0)
摘要:全量梯度下降 import numpy as np # 创建数据集X,y np.random.seed(1) X = np.random.rand(100, 1) y = 4 + 3*X + np.random.randn(100, 1) X_b = np.c_[np.ones((100, 1)), 阅读全文
posted @ 2024-04-05 16:57 华小电 阅读(53) 评论(0) 推荐(0)
摘要:import re content = [] srt = [] with open('input.vtt','r') as open_file: for lines in open_file: lines = lines.replace('WEBVTT','') #删除WEBVTT # vtt文件中 阅读全文
posted @ 2024-03-21 21:56 华小电 阅读(286) 评论(0) 推荐(0)
摘要:In Python, a decorator is a design pattern that allows you to modify the functionality of a function by wrapping it in another function. The outer fun 阅读全文
posted @ 2024-03-16 20:43 华小电 阅读(16) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 8 下一页