我正在使用美国证券交易委员会提供的开源财务报表数据:https://www.sec.gov/dera/data/financial-statement-data-sets.html
我计划在这些与我拥有的其他数据合并的数据上尝试数学建模。在我可以之前,我需要生成一个单一的大型数据帧组合来自每个季度的所有信息的num.txt。
第一步是将单个num.txt (来自任何一个季度)读取为熊猫df。问题是,列footnotes通常是空的,coreg通常是空的(但不总是),等等(据我所知,没有任何明确的标志张贴--但请在网站上自己看看!)。有人能帮我处理这件事吗?
发布于 2020-06-29 08:18:51
您需要使用制表符作为分隔符。FWIW,我读了其中一个文件,它有300多万行。因此,在遇到内存错误之前,您很可能无法使用pd.concat()将它们中的几个组合起来。可能还有其他方法来进行分析,但是如果您必须有一个非常大的表,您可以使用dask dataframe https://examples.dask.org/dataframe.html。
df = pd.read_csv('num.txt', sep='\t')
print (df.head(5))
adsh tag version coreg ddate qtrs uom value footnote
0 0000070502-20-000004 DerivativeNotionalAmount invest/2013 NaN 20191130 0 USD 1.043574e+10 NaN
1 0000070502-20-000004 DerivativeNotionalAmount invest/2013 NaN 20190531 0 USD 1.084328e+10 NaN
2 0000080424-20-000017 DerivativeNotionalAmount invest/2013 NaN 20190630 0 USD 1.730900e+10 NaN
3 0000080424-20-000017 DerivativeNotionalAmount invest/2013 NaN 20191231 0 USD 1.618200e+10 NaN
4 0000038777-20-000011 DerivativeNotionalAmount invest/2013 NaN 20191231 0 USD 6.000000e+07 NaNhttps://stackoverflow.com/questions/62629514
复制相似问题