我正在尝试使用luigi创建一个文件,该文件将使用csv并创建输出,根据csv中的特定列是否包含特定字符串将数据拆分为不同的数据帧
这是我创建的文件:
import luigi
import pandas as pd
import os
class read_file(luigi.Task):
fileName = luigi.Parameter()
def run(self):
full_file = pd.read_csv(self.fileName)
return full_file[['anonymous_id','channel','context_campaign_content',
'context_campaign_medium','context_campaign_name',
'context_campaign_source','context_campaign_term',
'timestamp','user_id','context_page_url',
'properties_url','properties_search','context_page_title',
'properties_path','context_user_agent','properties_referrer','rank']]
def output(self):
return full_file
class blog_readers(luigi.Task):
def run(self):
read_blog = read_file.full_file[read_file.full_file['properties_url'].str.contains('blog',regex=False)]
return read_blog
def requires(self):
return read_file
def output(self):
return read_blog
class logged_in(luigi.Task):
def run(self):
logged_in = read_file.full_file[read_file.full_file['properties_url'].str.contains('login',regex=False]
return logged_in
def requires(self):
return read_file
def output(self):
return logged_in
if __name__ == '__main__':
luigi.run()
但是,当我在终端上运行此文件时,
python cleanup.py --local-scheduler read_blog --fileName '/Users/**/Desktop/file.csv'
我遇到此错误消息
File "cleancopy.py", line 64
logged_in = read_file.full_file[read_file.full_file['properties_url'].str.contains('login',regex=False]
^
SyntaxError: invalid syntax
我不确定引起什么语法错误