Thomas CS50
Thomas CS50

Reputation: 13

Data reshape of big dataset

I would like to reshape my np array and present this into a DF. My initial dataset is 2930 rows.My header/column contains the following (80) elements:

Order;PID;MS SubClass;MS Zoning;Lot Frontage;Lot Area;Street;Alley;Lot Shape;Land Contour;Utilities;Lot Config;Land Slope;Neighborhood;Condition 1;Condition 2;Bldg Type;House Style;Overall Qual;Overall Cond;Year Built;Year Remod/Add;Roof Style;Roof Matl;Exterior 1st;Exterior 2nd;Mas Vnr Type;Mas Vnr Area;Exter Qual;Exter Cond;Foundation;Bsmt Qual;Bsmt Cond;Bsmt Exposure;BsmtFin Type 1;BsmtFin SF 1;BsmtFin Type 2;BsmtFin SF 2;Bsmt Unf SF;Total Bsmt SF;Heating;Heating QC;Central Air;Electrical;1st Flr SF;2nd Flr SF;Low Qual Fin SF;Gr Liv Area;Bsmt Full Bath;Bsmt Half Bath;Full Bath;Half Bath;Bedroom AbvGr;Kitchen AbvGr;Kitchen Qual;TotRms AbvGrd;Functional;Fireplaces;Fireplace Qu;Garage Type;Garage Yr Blt;Garage Finish;Garage Cars;Garage Area;Garage Qual;Garage Cond;Paved Drive;Wood Deck SF;Open Porch SF;Enclosed Porch;3Ssn Porch;Screen Porch;Pool Area;Pool QC;Fence;Misc Feature;Misc Val;Mo Sold;Yr Sold;Sale Type;Sale Condition;SalePrice

I tried the following code:

df = pd.DataFrame(np.array(results[1:]).reshape(2930,15,-1), columns = results[0])

Result ==>

ValueError: cannot reshape array of size 2930 into shape (2930,15,newaxis)

Why is this not possible? Possible solutions to get my get dataset into a DataFrame? Thank you, much appreciated.

Upvotes: 0

Views: 238

Answers (1)

EHB
EHB

Reputation: 1187

If you're reading it in from a file initially, you can use pd.read_csv(sep=';') to parse each column...

Upvotes: 1

Related Questions