我正在尝试使用 AWS Lambda 将 csv 文件写入 S3 存储桶,为此我使用了以下代码:
data=[[1,2,3],[23,56,98]]
with open("s3://my_bucket/my_file.csv", "w") as f:
f.write(data)
Run Code Online (Sandbox Code Playgroud)
这会引发以下错误:
[Errno 2] No such file or directory: u's3://my_bucket/my_file.csv': IOError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 51, in lambda_handler
with open("s3://my_bucket/my_file.csv", "w") as f:
IOError: [Errno 2] No such file or directory: u's3://my_bucket/my_file.csv'
Run Code Online (Sandbox Code Playgroud)
请问我能帮上忙吗?
PS:我使用的是 python 2.7
提前致谢
Redshift我正在尝试从我的函数连接到我的数据库AWS Lambda:
con = psycopg2.connect(
dbname="my_dbname",
host="my_url",
port= 5439,
user="username",
password="my_password")
cur = con.cursor()
Run Code Online (Sandbox Code Playgroud)
但我无法访问我的数据库,我的函数引发以下错误:
OperationalError: could not connect to server: Connection timed out
Is the server running on host "my_url" (54.217.83.88) and accepting
TCP/IP connections on port 5439?
Run Code Online (Sandbox Code Playgroud)
我可以得到一些帮助吗?(如果可能的话,我希望得到一个非常详细的答案,因为我是 AWS 新手)
PS:我知道我必须配置VPC,但我不知道具体该怎么做
提前谢谢你
我试图根据需要在同一行中满足的 4 个条件从 Pandas DataFrame 中删除一些行。所以我尝试了以下命令:
my_data.drop(my_data[(my_data.column1 is None) & (my_data.column2 is None) & (my_data.column3 is None) & (my_data.column4 is None)].index, inplace=True)
Run Code Online (Sandbox Code Playgroud)
它抛出这个错误: 在此处输入图像描述
我也试过:
my_data= my_data.loc[my_data[(my_data.column1 is None) & (my_data.column2 is None) & (my_data.column3 is None) & (my_data.column4 is None), :]
Run Code Online (Sandbox Code Playgroud)
但没有成功
我能得到一些帮助吗:)
我正在研究 python 3.5