Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何动态设置变量-python,pandas_Python_Csv_Pandas_Dynamic_Dataframe - Fatal编程技术网

如何动态设置变量-python,pandas

如何动态设置变量-python,pandas,python,csv,pandas,dynamic,dataframe,Python,Csv,Pandas,Dynamic,Dataframe,我想应用下面的公式,当我动态输入“x”值来绘制图形时,得到“y” y=y0+(y1-y0)*(x-x0/x1-x0) 如果“平均”值为0(例如index4,5 index8,9,10) 1) 问问题“是否要插入?” 2) 如果是,请输入“x”值 3) 使用公式计算(重复1-3直到答案为否) 4) 如果答案为“否”,请完成该程序。 >>>import pandas as pd >>>import numpy as np >>>from pand

我想应用下面的公式,当我动态输入“x”值来绘制图形时,得到“y”

y=y0+(y1-y0)*(x-x0/x1-x0)

如果“平均”值为0(例如index4,5 index8,9,10)
1) 问问题“是否要插入?”
2) 如果是,请输入“x”值
3) 使用公式计算(重复1-3直到答案为否)
4) 如果答案为“否”,请完成该程序。

>>>import pandas as pd
>>>import numpy as np
>>>from pandas import Series, DataFrame

>>>rawData = pd.read_csv('wow.txt')
>>>rawData 
     time       mean    
0    0.005           0                   
1    0.010      258.64                   
2    0.015      258.43                   
3    0.020      253.72          
4    0.025           0                   
5    0.030           0                   
6    0.035      253.84             
7    0.040      254.17           
8    0.045           0                   
9    0.050           0               
10   0.055           0      
11   0.060      254.73    
12   0.065      254.90      
             .
             . 
             .
489  4.180      167.46
时间(x轴)平均值(y轴)
0    0.005                 0                   
1    0.010            258.64                   
2    0.015            258.43                   
3    0.020  
请原谅打字错误,正在使用手机

请原谅打字错误,正在使用手机

     time(x-axis) mean(y-axis)         
0    0.005                 0                   
1    0.010            258.64                   
2    0.015            258.43                   
3    0.020  <--x0     253.72      <-- y0        
4    0.025                 0                   
5    0.030                 0                   
6    0.035  <--x1     253.84      <-- y1         
7    0.040  <--x0     254.17      <-- y0             
8    0.045                 0                   
9    0.050                 0               
10   0.055                 0      
11   0.060  <--x1     254.73      <-- y1
12   0.065            254.90      
             .
             . 
             .
489  4.180            167.46
for i in df.index:
    if df.mean [i]=0:
        answer=input ("Do you want to interpolate?")
        if answer="Y":
            x1 = df.loc[df.mean > 0].index[1]  
            y1 = df.loc[df.time > 0].index[1] 
            Interpolate eqn
        else:
            Process
    else:
         x0 = df.time [i]
         y0 = df.mean[i]