【发布时间】:2021-03-27 14:46:29
【问题描述】:
我在 python 上遇到了问题,我尝试从 R 中获取值,因为它在本网站 https://reliabilityanalyticstoolkit.appspot.com/active_redundancy_integrate_details 上给出并得到一个错误
%运行 test0.py 回溯(最近一次通话最后): 文件“C:\Users\Amine13\Desktop\COURS 3I\math maintenance\test0.py”,第 21 行,在 x=df_data[:,0] getitem 中的文件“C:\Users\Amine13\AppData\Roaming\Python\Python37\site-packages\pandas\core\frame.py”,第 2906 行 索引器 = self.columns.get_loc(key) 文件“C:\Users\Amine13\AppData\Roaming\Python\Python37\site-packages\pandas\core\indexes\base.py”,第 2898 行,在 get_loc 返回 self._engine.get_loc(casted_key) 文件“pandas_libs\index.pyx”,第 70 行,在 pandas._libs.index.IndexEngine.get_loc 文件“pandas_libs\index.pyx”,第 75 行,在 pandas._libs.index.IndexEngine.get_loc TypeError: '(slice(None, None, None), 0)' is an invalid key
这是我的代码:
import numpy as np
import matplotlib.pyplot as plt
import math
import pandas as pd
from math import *
df_data = pd.read_csv('a09.csv', sep=';', decimal=',')
df_data[['duree_de_vie']]
#dat=np.loadtxt (fname=r"C:\Users\Amine13\Desktop\COURS 3I\math maintenance\a09.txt")
x=df_data[:,0]
y=df_data[:,1]
R = lambda y, gamma, eta, beta: (2*exp(-((y-gamma)/eta)**beta)**1*(1-exp(-((y-gamma)/eta)**beta))**1* + 1*exp(-((y-gamma)/eta)**beta)**2*(1-exp(-((y-gamma)/eta)**beta))**0)
任何导致此错误的想法都可以帮助我解决错误。
注意:我将 t 替换为 y(来自网站)
感谢您的回复
【问题讨论】:
-
使用
.loc[]或.iloc[]来索引数据框或熊猫系列
标签: python pandas statistics weibull