Issue
I am running the following code and I get ValueError: Columns must be same length as key
as an error:
BECS_mapping[['length']] = BECS_mapping.Label.str.len()
BECS_mapping=BECS_mapping.sort_values('length', ascending=False)
BECS_mapping
the table this code is meant to work with is the following:
Database Name Label
3BECSDriort Drilling & Drilling Support
3BECSExpion Exploration & Production
3BECSTheoal Thermal Coal
3BECSEleent Electrical Equipment
3BECSMideam Midstream
3BECSResITs Residential Owners & Developers + REITs
3BECSOffITs Office Owners & Developers + REITs
3BECSAiring Air Freight, Courier, Logistics and Trucking
3BECSAirnes Airlines
3BECSOilent Oilfield Services & Equipment
3BECSAlcges Alcoholic Beverages
3BECSSteers Steel Producers
3BECSComces Commercial Support Services
3BECSEngion Engineering & Construction
3BECSPlaing Plastic Containers & Packaging
3BECSTecnts Technology Hardware, Equipment and Components
3BECSDivals Diversified Industrials
3BECSPacood Packaged Food
3BECSRefing Refining & Marketing
3BECSMulITs Multi Asset Owners & Developers + REITs
3BECSFacent Factory Machinery & Equipment
3BECSRaices Rail Freight and Transit Services
3BECSEleist Electric Transmission & Dist
3BECSEMSODM EMS/ODM
3BECSConail Consumer Staples Retail
3BECSWasent Waste Management
3BECSWinent Wind Energy Equipment
3BECSCement Cement
3BECSAgrals Agricultural Chemicals
3BECSHotITs Hotel Owners & Developers +REITs
3BECSSolent Solar Energy Equipment
3BECSTraces Transport Operations & Services
3BECSPreing Precious Metals and Mineral & Precious Stone Mining
3BECSHeaITs Health Care Owners & Developers + REITs
3BECSBasals Basic & Diversified Chemicals
3BECSPaping Paper Containers & Packaging
3BECSSemors Semiconductors
3BECSRetITs Retail Owners & Developers + REITs
3BECSMaring Marine Shipping
3BECSIndrod Industrial Intermediate Prod
3BECSIntils Integrated Oils
3BECSMeting Metal Containers & Packaging
3BECSFooers Food & Beverage Wholesalers
3BECSGasies Gas Utilities
3BECSBuials Building Materials
3BECSIntion Integrated Electric Utilities and Power Generation
3BECSAirrts Aircraft & Parts
3BECSSpeals Specialty Chemicals
3BECSNonges Non-Alcoholic Beverages
3BECSAgrers Agricultural Producers & Wholesalers
3BECSMetoal Metallurgical Coal
3BECSIroals Iron and Base Metals
3BECSIndEIT Industrial, Specialty and Other REIT
3BECSTraery Transportation Equipment & Mobile Machinery
3BECSDefnse Defense
3BECSTobcco Tobacco
3BECSSofces Software and Tech Services
3BECSHomcts Home Products & Personal Care Products
Solution
You don't need use list to create length
column
BECS_mapping['length'] = BECS_mapping.Label.str.len()
Answered By - Ynjxsjmh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.