有没有办法捕获在 pandas/awswrangler 中使用通配符读取的多个镶木地板文件的输入文件名?
这是以下火花问题的确切python类似物:
有没有方法可以捕获使用Spark中的通配符读取的多个Parquet文件的输入文件名?
我正在使用(使用(熊猫和awswrangler。
是否可以根据此Quesiton的火花版本来检索包含加载到最终组合数据框架中的每一行的原始文件名的列?
更新:这可能是一种做到这一点的方法 - 读取用Pyarrow保存为镶木的数据框,将文件名保存在列中
update2:当前的问题是 https:// stackoverflow.com/a/59682461/1021819
This is the exact python analogue of the following Spark question:
I am reading in a wildcard list of parquet files using (variously) pandas and awswrangler.
Is there a way to retrieve a column containing the original filename of each row loaded into the eventual combined dataframe, exactly as per the Spark version of this quesiton?
Update: This is possibly a way to do it - Reading DataFrames saved as parquet with pyarrow, save filenames in columns
Update2: The present question is the reverse of https://stackoverflow.com/a/59682461/1021819
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加载时,您需要将文件名作为新列将其添加到每个数据框架中。例如,这是如何使用一组CSV文件来执行此操作,因为这很容易作为示例运行。您将遵循类似的模式用于镶木点文件。
You'll need to add the filename as a new column to each dataframe as you load them. For example, here is how to do this with a set of CSV files since that is easier to run as an example. You'll follow a similar pattern for parquet files.