所以我对此很陌生,请原谅我的愚蠢问题。
我有一些需要分析的数据,我通常只使用 excel 它似乎无法完成这项工作。
我有 .csv 文件,其中包含一年内每一秒的数据。数据由简单的时间戳和 valueX 组成。
我需要分析这些值以查看值 X 是否低于某个值,如果是,我需要执行各种计算。值 A 与 X 成正比并且只是瞬时的,那么值 B 是与 A 成正比的计数器。
你能推荐一种最好和最容易做到这一点的方法/语言/软件吗?除了使用excel和一点matlab和python之外,我在数据分析/大数据方面没有太多经验。
提前致谢
编辑:感谢您的回复,我的数据是这样的......
我有一个一月值的文本文件。
01/02/2016 00:00:00,49.972332
01/02/2016 00:00:01,49.9690056
01/02/2016 00:00:02,49.9600029
01/02/2016 00:00:03,49.9490013
01/02/2016 00:00:04,49.9430046
每个月都有不同的文本文件,有些文件顶部有文本或注释,我需要清理它们。
在某些情况下,第二个值是电网频率,如果低于某个阈值,则构成电网故障。我需要知道这些故障发生的时间、频率、f 值下降的幅度等。
编辑2: 感谢提示,我已经能够读取我的数据,清理它并将其合并到一个数据帧中。我现在尝试向数据框中添加一些额外的列,这些列依赖于 col 1 值但遇到了一些麻烦。
"Read in month csv files and create dataframes"
df_jan_short = pd.read_csv('2016_01_short.csv', header = None ,parse_dates = [0], index_col = 0, names = ['timestamp','Freq'],squeeze= True)
df_feb_short = pd.read_csv('2016_02_short.csv', header = None ,parse_dates = [0], index_col = 0, names = ['timestamp','Freq'],squeeze= True)
"Combine dataframes into one dataframe for year" months_short = [df_jan_short, df_feb_short] year_short = pd.concat(months_short)
"Repalce NaN values in df with 50.00 Hz"
year_short.fillna(50.00,inplace = True)
"Check what range freq is in"
year_short['Case'] = 'No Case'
year_short['Case'](year_short['Freq'] > Fc & year_short['Freq'] < Ff ) = 'A' year_short['Case'](year_short['Freq'] > Fa & year_short['Freq'] < Fc ) = 'B'
year_short['Case'](year_short['Freq'] < Fa ) = 'C'
year_short['Case'](year_short['Freq'] > Ff & year_short['Freq'] < Fh ) = 'G'
year_short['Case'](year_short['Freq'] > Fh ) = 'H'
但我收到以下错误...
runfile('C:/Users/ShaneOKeeffe/Documents/Grid Freq/Py/4.py', wdir='C:/Users/ShaneOKeeffe/Documents/Grid Freq/Py')
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-74-3a0fbc1f23f6>", line 1, in <module>
runfile('C:/Users/ShaneOKeeffe/Documents/Grid Freq/Py/4.py', wdir='C:/Users/ShaneOKeeffe/Documents/Grid Freq/Py')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/ShaneOKeeffe/Documents/Grid Freq/Py/4.py", line 48
year_short['Case'](year_short['Freq'] > Fc & year_short['Freq'] < Ff ) = 'A'
^
SyntaxError: can't assign to function call