read_csv()不';t在需要python引擎的地方使用StreamingBody对象
使用pandasread_csv()不';t在需要python引擎的地方使用StreamingBody对象,python,pandas,amazon-s3,Python,Pandas,Amazon S3,使用pandasread\u csv()时遇到问题。数据作为StreamingBody对象从s3中读取,注意到它只有在使用c引擎解析器时才起作用。(根据pandas[documentation][1],skipfooter仅适用于python引擎解析器) 以前有没有人遇到过类似的问题?或者有什么建议来解决这个问题?谢谢 以下是我如何重新制作这一期 import boto3 import s3fs import pandas as pd s3 = boto3.client("s3") respo
read\u csv()
时遇到问题。数据作为StreamingBody
对象从s3中读取,注意到它只有在使用c引擎解析器时才起作用。(根据pandas[documentation][1],skipfooter仅适用于python引擎解析器)
以前有没有人遇到过类似的问题?或者有什么建议来解决这个问题?谢谢
以下是我如何重新制作这一期
import boto3
import s3fs
import pandas as pd
s3 = boto3.client("s3")
response = s3.get_object(Bucket="df-raw-869771", Key="csv/customer-01.csv")
pd.read_csv(response["Body"])
customer_id|store_id|first_name|last_name|email|address_id|activebool|dw_insert_date|dw_update_date|active
0 9|2|MARGARET|MOORE|MARGARET.MOORE@sakilacustom...
1 13|2|KAREN|JACKSON|KAREN.JACKSON@sakilacustome...
2 17|1|DONNA|THOMPSON|DONNA.THOMPSON@sakilacusto...
3 21|1|MICHELLE|CLARK|MICHELLE.CLARK@sakilacusto...
4 25|1|DEBORAH|WALKER|DEBORAH.WALKER@sakilacusto...
... ...
1188 587|1|SERGIO|STANFIELD|SERGIO.STANFIELD@sakila...
1189 591|1|KENT|ARSENAULT|KENT.ARSENAULT@sakilacust...
1190 595|1|TERRENCE|GUNDERSON|TERRENCE.GUNDERSON@sa...
1191 599|2|AUSTIN|CINTRON|AUSTIN.CINTRON@sakilacust...
1192 4|2|BARBARA|JONES|BARBARA@sakilacustomer.org|8...
[1193 rows x 1 columns]
如果传入skipfooter参数
import boto3
import s3fs
import pandas as pd
s3 = boto3.client("s3")
response = s3.get_object(Bucket="df-raw-869771", Key="csv/customer-01.csv")
pd.read_csv(response["Body"], skipfooter=1)
__main__:1: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support skipfooter; you can avoid this warning by specifying engine='python'.
99 117 115 116 111 109 101 114 95 105 100 124 115.1 116.1 111.1 ... 114.28 103.11 124.112 53.6 55.4 124.113 65.51 99.26 116.33 105.31 118.13 101.35 124.114 49.70 51.21
0 45 49 49 45 50 48 49 57 124 124 49 10 53 55 124 ... 69 83 84 124 69 68 78 65 46 87 69 83 84 64 115
1 97 107 105 108 97 99 117 115 116 111 109 101 114 46 111 ... 76 68 73 78 69 46 80 69 82 75 73 78 83 64 115
2 97 107 105 108 97 99 117 115 116 111 109 101 114 46 111 ... 73 76 76 73 65 77 83 79 78 64 115 97 107 105 108
3 97 99 117 115 116 111 109 101 114 46 111 114 103 124 50 ... 114 103 124 50 55 48 124 65 99 116 105 118 101 124 49
4 51 45 49 49 45 50 48 49 57 124 124 49 10 50 54 ... 115 97 107 105 108 97 99 117 115 116 111 109 101 114 46
.. .. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
84 99 116 105 118 101 124 49 51 45 49 49 45 50 48 49 ... 51 45 49 49 45 50 48 49 57 124 124 49 10 51 56
85 51 124 49 124 77 65 82 84 73 78 124 66 65 76 69 ... 51 53 124 50 124 82 73 67 75 89 124 83 72 69 76
86 66 89 124 82 73 67 75 89 46 83 72 69 76 66 89 ... 88 84 69 82 124 72 69 67 84 79 82 46 80 79 73
87 78 68 69 88 84 69 82 64 115 97 107 105 108 97 99 ... 103 124 53 52 53 124 65 99 116 105 118 101 124 49 51
88 45 49 49 45 50 48 49 57 124 124 49 10 53 52 51 ... 116 111 109 101 114 46 111 114 103 124 53 57 55 124 65
[89 rows x 1024 columns]
您可以单独使用skipfooter参数来尝试
read_csv()
,还是在不使用skipfooter参数之前尝试?谢谢您的回答。如果使用带有或不带有skipfooter的S3URL,根本没有问题。。。因此,当同时使用StreamBody对象和python引擎解析时,似乎有什么东西停止了工作。。。你的意思是说,当使用一个与skipfooter第一,或自己?对不起,我可能没有按照你的问题。。。skipfooter
参数不能单独使用……如果我解释得不好,很抱歉。在您共享的代码中,您正在对同一输入运行pandas.read_csv()
两次。我的意思是,您应该测试一个运行pandas.read\u csv()
一次的短程序,使用skipfooter
参数。