0 Replies - 476 Views - Last Post: 14 May 2015 - 05:31 PM Rate Topic: -----

#1 CodingStudent   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-May 15

ValueError: cannot copy sequence with size * to array axis with dimens

Posted 14 May 2015 - 05:31 PM

I thought changing the dtype to 'object' would have solved this...but in fact it hasn't.

Traceback states this is the problem:

X=np.array([dfTrain],dtype='object')

There are mixed types in these fields (123, .45, ABC).

Below is the code I have:

import pandas as pd
from sklearn.ensemble import RandomForestClassifier
import numpy as np
from sklearn import preprocessing
data_dir='C:/Users/Owner/Desktop/Data/XYZ/'
train = pd.read_csv(data_dir+'ABC_Train.csv')
test = pd.read_csv(data_dir+'ABC_Test.csv')

# Get labels
labels = train.Dependent.values


# clean up junk - missing
dfTrain = train
dfTrain.fillna("unk",inplace=True)
dfTest = test
dfTest.fillna("unk",inplace=True)


X=np.array([dfTrain],dtype='object')
y=np.array(labels)
Xt=np.array(dfTest,dytpe='object')



Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1