我刚开始用python。我只是想验证一下,假设我将一些.root文件传递给一个方法,该方法首先将其转换为dataframe,然后它们洗牌其中的事件,并以.h5格式给出输出
def loadDF(self, rndm = 12345):
df = rpd.read_root(self.file_name,self.tree_name)
rndseed = rndm
np.random.seed(rndseed)
index = list(df.index)
np.random.shuffle(index)
self.df = df
hdf = pd.HDFStore(self.tree_name + '.h5')
hdf.put('hdf', self.df)
self.hdf = hdf
hdf.close()
现在假设我想从.root文件中得到相同的无序数据帧。我想要的就是现在。h5不应该被创造出来。那么下面的方法正确吗
def loadDF(self, rndm = 12345):
ddf = rpd.read_root(self.file_name,self.tree_name)
rndseed = rndm
np.random.seed(rndseed)
index = list(ddf.index)
np.random.shuffle(index)
self.ddf = ddf
简言之,通过“np.random.seed(same\ u number)”我们可以回溯相同的随机化数据吗
random.seed
docs依次引用random.RandomState
类的documentation,这里我们有了关于你问题的确定词因此,只要不需要修复
RandomState
类或其中一个方法中的bug,就可以保证结果是相同的在我看来,关于你的问题
不是肯定的,但是肯定的
相关问题 更多 >
编程相关推荐