bhjghjh bhjghjh - 1 month ago 12
Python Question

SyntaxError: non-keyword arg after keyword arg, with no apparent reason

I have a .dat file which I first want to convert into a .csv file and then plot some of the rows against time, my scripts is as follows :

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

# 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)

def your_func(row):
return (row['global_beta'])

columns_to_keep = ['#time', 'global_beta', 'max_dens', 'max_temp', 'dens@max_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


I executed the script with
python flash.dat
and got the following error :

File "", line 46
dataframe.plot(x='#time', 'Nuclear_Burning', style='r')
SyntaxError: non-keyword arg after keyword arg

I don't see the apparent reason to find the error, please help me fix this.


The argument 'Nuclear_Burning' follows a keyword argument x. Once you start using keywords in an argument list, you have to keep on using keyword arguments.