
python
喵喵喵喵诺
这个作者很懒,什么都没留下…
展开
-
pandas学习第二天
获取某一列#method1df.get('Cabin')#method2df['Cabin']#method3df.Cabin获取数据中NAN的个数num=df.isnull().sum().sum()对缺失值进行替换#method1df.dropna(axis=1)#method2df.fillna(0)#df1 = pd.DataFrame(np.zeros(df.shape))#df.combine_first(df1)查看重复值df.duplicated()原创 2021-09-22 20:16:07 · 138 阅读 · 0 评论 -
pandas中数据基础操作
具体可参考pandas官方文档1.使用pandas库载入表格数据首先数据路径存在两种情况,一种是相对路径(ps:就是相对当前代码文件的路径位置);一种是绝对路径(ps:即在整个盘下的位置,绝对路径可以通过os.getcwd()方法来获取)路径中使用单/或者双\相对路径绝对路径C:/Users/Administrator/Documents/kaggle_data/test.csv而pandas读取文本的方法有两种:pd.read_cv(),pd.read_table()两者存在的区别就原创 2021-09-13 23:18:30 · 425 阅读 · 0 评论 -
matplotlib画图
from matplotlib.colors import Normalizeimport matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import ImageGridimport numpy as npimport matplotlibfrom typing import List利用上面的头文件进行画图figure(num=None, figsize=None, dpi=None, facecolor=None, edgeco原创 2021-06-14 09:08:50 · 197 阅读 · 0 评论 -
关于git与sacred的那些问题
You can disable git with: sacred.Experiment(…, save_git_info=False)卸载原有的sacred,重新进行pip install就可以了原创 2021-04-14 19:27:04 · 959 阅读 · 6 评论 -
程序里面的一些函数
tensor([[[[ 3], [ 12], [ 21], [ 30]],原创 2020-10-21 15:41:13 · 582 阅读 · 1 评论 -
torch里面的函数
import torchfrom torch_scatter import scattersrc = torch.range(1,24).view(2,6,2)index = torch.tensor([0, 1, 0, 1, 2, 1])# Broadcasting in the first and last dim.out = scatter(src, index, dim=1, reduce="sum")print(src)print(out)Pytorch学习 (二十六)----原创 2020-11-02 20:18:41 · 1022 阅读 · 0 评论 -
程序里面遇到的问题
创建元组使得两个列表的元素实现多对多for dic itertools.product([列表1],[列表2])Python product函数介绍if __name__ == '__main__':在代码里面总是会有这句,而这段代码下面接的一般都是测试代码,如果存在其他代码对这个py文件里面的函数与类进行调用,就可以很好的避免运行这段代码下的测试部分参考python中 “name“的实际应用from gcn import GCN, GCNWithJKfrom graph_sage i原创 2020-10-21 15:41:04 · 259 阅读 · 1 评论 -
将tensor变量进行保存到本地文件
file_handle=open('1.txt',mode='w')#w 写入模式#将tensor变量转化为numpy类型x = index.cpu().numpy()#将numpy类型转化为list类型x=x.tolist()#将list转化为string类型strNums=[str(x_i) for x_i in x]str=",".join(strNums)#将str类型数据存入本地文件1.txt中file_handle.write(str)写入本地的数据类型目前知道的只有str原创 2020-11-11 21:04:40 · 9256 阅读 · 0 评论