.csv 파일로 변환하고 시간에 따라 일부 행을 플롯하려는 .dat 파일이 있습니다. 스크립트는 다음과 같습니다. SyntaxError : 키워드 인수 뒤의 키워드가 아닌 인수 arg (명백한 이유 없음)
import pandas as pd
import numpy as np
from sys import argv
from pylab import *
import csv
script, filename = argv
txt = open(filename)
print "Here's your file %r:" % filename
print txt.read()
# read flash.dat to a list of lists
datContent = [i.strip().split() for i in open("./flash.dat").readlines()]
# write it as a new CSV file
with open("./flash.csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(datContent)
def your_func(row):
return (row['global_beta'])
columns_to_keep = ['#time', 'global_beta', 'max_dens', 'max_temp', '[email protected]_temp']
dataframe = pd.read_csv("./flash.csv", usecols=columns_to_keep)
dataframe['Nuclear_Burning'] = dataframe.apply(your_func, axis=1)
pd.set_option('display.height', 1000)
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
dataframe.plot(x='#time', 'Nuclear_Burning', style='r')
print dataframe
show()
나는
python csv_flash_dat_file.py flash.dat
으로 스크립트를 실행하고 다음과 같은 오류 있어요 :
File "csv_flash_dat_file.py", line 46
dataframe.plot(x='#time', 'Nuclear_Burning', style='r')
SyntaxError: non-keyword arg after keyword arg
내가 오류를 찾기 위해 이유없이 표시되지 않는이, 내가이 문제를 해결하는 데 도움 바랍니다.
오, 물론 지금은 y = 'Nuclear_Burning' – bhjghjh