Background
I take the original model and prepare to run a new dataset. Of course, the columns will be different
the new dataset does not have a head, so I’m stupid to count a number of columns (it should be wrong. My original number of 38 is actually 40)
and report valueerror: length mismatch: expected axis has 40 elements, new values have 38 elements
error
Solution ideas
My English is poor, so Google translated what this sentence means
valueerror: length mismatch: the expected axis has 40 elements and the new value has 38 elements
That is to say, I counted wrong
in order to prove it, I must output. The shape result is (100000, 40)
OK, then I’ll recognize it and change it
Data processing and analysis
Before getting the dataset, you’d better take a shape to see how many rows and columns
train_df=pd.read_csv('data/train_small.txt',header=None,sep='\t')
print(train_df.shape)
Get (10000, 40)
For a dataset without a head, you need to define a header name
train_df.columns=['click']+['f'+str(i) for i in range(39)]
features=['f'+str(i) for i in range(39)]
It’s that simple
I write 39 because the target value in front of me has this
Error reason
It’s mainly because you can’t count.
it’s clearly said that there are 40 columns, so don’t be stubborn. Only 38 columns will be finished. Small mistakes are very simple
Read More:
- Solve the unmarshalling error: unexpected element (URI: “local:” name “). Expected elements are
- ValueError: not enough values to unpack (expected 6, got 1)
- Python3-ValueError:not enough values to unpack (expected 2, got 0)
- ValueError: not enough values to unpack (expected 2, got 0)
- Error occurred when Python called cv2.findcontours: valueerror: not enough values to unpack (expected 3, got 2)
- Python uses the priority queue to get the maximum k elements
- for k, v in k_map: ValueError: too many values to unpack (expected 2)
- V-for styles individual elements
- Python random selects elements randomly from a collection
- Remove array duplicate elements
- ArcGIS import database elements error 000210
- JQuery is a solution to the disappearance of listening events after adding elements with append
- Selenium: 8 Ways to Locate Elements
- Several ways to center elements horizontally and vertically
- ValueError: too many values to unpack
- [Vue warn]: Do not use built-in or reserved HTML elements as component id: article
- During the development of vue, v-for reported an error [vue/require-v-for-key] Elements in iteration expect to have’v-bind:key’ directives.
- ValueError: need more than 0 values to unpack
- Error: improvement of not enough values to unpack (expected 2, got 1)
- After JQ gets the tag element itself, it gets its own HTML text format (find only finds one level of child elements)