I am trying to format a list of lists as a Pandas data frame. However I get this error ‘numpy.float64’ object has no attribute ‘DataFrame’. The code I am trying to run, works in previous instances in the same file but when it tries to run again it gets this error message. The line of code is:
iteration_1_2 = pd.DataFrame([values_ab,values_be,values_ac,values_de,values_cd,values_cg2,values_dg,values_gf,values_cf3,values_gh,values_eh])
when running this code:
iteration_1 = pd.DataFrame([values_ab,values_be,values_ac,values_de,values_cd,values_cg2,values_dg,values_gf,values_cf3,values_gh,values_eh])
with this data:
[[4.190046655460235, 0.7374482113610015, 660968865.9874631, 0.007429378995396333, 0.12979088519953627, 5.542373154194743, 2487.4170716026006, -2.5159804968725354], [14.075402804005158, 3.198501659968362, 221129842.1854887, 0.04671917477977774, 0.726829136705722, 4.261178858294564, 1912.4170716026006, -3.2724518791790045], [-9.526592679946594, 1.0688836986900079, 447857908.22377455, 0.007708788759017264, 0.11992875099301889, -9.05210099910294, -4062.5829283974, 1.5404714069944507], [-5.116702294343766, 3.7645508027893153, 379473890.11986125, 0.008257398918645053, 2.7697219676915488, -1.0916590706320144, -489.9365908996481, -24.505907770612723], [-1.0779745477950637, 0.35313501974483547, 193336993.3496227, 0.0076592712238461895, 0.11568393931495048, -3.5845583109892734, -1608.7497699719859, 14.840702664165311], [-7.6698589521369875, 3.44223269771908, 529207098.58473366, 0.008081694114075154, 1.5448740347363232, -1.1476527636447929, -515.066560323783, -94.14966472903546], [2.2897516785905996, 1.6846566448384608, 258253064.10935003, 0.008105013832224063, 1.2394654134483627, 2.158674641426778, 968.8131790723379, 37.03636437067364], [-0.38658828042136245, 0.4448738980848909, 97844512.44944407, 0.00804351476183602, 0.5119471934884591, -1.5569665733102283, -698.7665981016305, 44.18737228431783], [-1.1961096975601655, 0.5368140322650023, 223928954.11188728, 0.007743005123342827, 0.24092213768053308, -2.916146608960852, -1308.7665981016303, 23.59218202462511], [-32.96885613029067, 9.54607911695126, 964236933.9111227, 0.008240494426828867, 2.7640518114114356, -3.860620181590355, -1732.6463374977513, 10.54146674626774], [51.50192826675125, 11.247720392271514, 1136348042.544721, 0.008238822504888114, 2.4564364535530196, 4.171911012705545, 1872.3536625022484, -9.754905878927788]]
A pandas data frame is constructed
However when running this code:
iteration_1_2 = pd.DataFrame([values_ab,values_be,values_ac,values_de,values_cd,values_cg2,values_dg,values_gf,values_cf3,values_gh,values_eh])
with this data:
[[9.08663010411883, 1.5992468983249142, 660968865.9874631, 0.01611151960480052, 0.2814674541051849, 6.400871496704488, 2872.711127720974, 11.233678339840338], [5.122874323259273, 1.164124555077854, 221129842.1854887, 0.017003880046337454, 0.264536253326046, 5.119677200804309, 2297.711127720974, 14.044895540940386], [-21.012319920535788, 2.3575822950841157, 447857908.22377455, 0.01700288246240091, 0.2645207335084378, -8.193602656593194, -3677.288872279026, -8.775789417951591], [-11.701948057914635, 8.609564407200144, 379473890.11986125, 0.018884751873541963, 6.334381157297418, -0.2320410276730483, -104.14001321966408, -485.74987763187426], [-2.346779676817566, 0.7687844663910391, 193336993.3496227, 0.016674440119316288, 0.2518470573111667, -2.731767469178051, -1226.0172401671093, -11.743942508774632], [-17.364878718693912, 7.793357568949828, 529207098.58473366, 0.01829729060315984, 3.497658876944683, -1.1328061363181068, -508.4033939795663, -96.6942022499936], [5.169368451234128, 3.8032992801866827, 258253064.10935003, 0.018297967938123515, 2.798230683520956, 2.165501842574521, 971.8772269474451, 37.23487050767307], [-0.8557401150829987, 0.9847593939724354, 97844512.44944407, 0.01780488079065161, 1.1332308102944333, -1.566105699938392, -702.8682381323504, 44.51307103642904], [-2.6266902883625725, 1.1788586014171225, 223928954.11188728, 0.017003855417034773, 0.5290717403160046, -2.9252857355890156, -1312.8682381323501, 23.830893995685955], [-75.55279568663816, 21.876190131718197, 964236933.9111227, 0.018884258201941832, 6.334215568461373, -3.861739882039576, -1733.1488590593617, 10.567404992480729], [118.04759862546024, 25.780906210757447, 1136348042.544721, 0.018884209677860104, 5.630399370991699, 4.170791312256324, 1871.8511409406383, -9.784370939204397]]
This error message is given: AttributeError: ‘numpy.float64’ object has no attribute ‘DataFrame’
MSU Running is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.