繁体   English   中英

如何修改我的代码以在 python 上没有此错误?

[英]how can i modify my code to not having this error on python?

我在 python 上遇到了问题,我尝试从 R 获取值,因为它在本网站https_.comtailability_redundancy_integrate上给出。

%Run test0.py Traceback(最近一次调用最后):文件“C:\Users\Amine13\Desktop\COURS 3I\math maintenance\test0.py”,第 21 行,在 x=df_data[:,0] 文件“C :\Users\Amine13\AppData\Roaming\Python\Python37\site-packages\pandas\core\frame.py",第 2906 行,在getitem indexer = self.columns.get_loc(key) File "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.IndexEngine.get_loc 文件“pandas_libs\index.pyx”文件“pandas_libs\index.pyx”第 75 行中类型错误:'(0)(无,无,无)无效的密钥

这是我的代码:

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(来自网站)

感谢您的回复

此错误是由于未正确调用列索引(而不是在您的最后一行代码中)引起的。 以下是您在 Pandas 中的操作方法:

x=df_data.iloc[:,0] # Get the first column
y=df_data.iloc[:,1] # Get the second column

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM