I am attempting to inscribe some info to check out right into an Artificial intelligence version utilizing the adhering to

import numpy as npimport pandas as pdimport matplotlib.pyplot as pyDataset = pd.read _ csv("filename.csv", sep=",")X = Dataset.iloc <:,: -1> valuesY = Dataset.iloc <:,18> valuesfrom sklearn.preprocessing import LabelEncoder, OneHotEncoderlabelencoder_X = LabelEncoder()X <:, 0> = labelencoder_X. fit_transform(X <:, 0> onehotencoder = OneHotEncoder(categorical_features = <0> X = onehotencoder.fit _ change(X). toarray()nonetheless I am obtaining a mistake that reviews

IndexError: solitary positional indexer is out-of-bounds
python
Share
Boost this inquiry
Comply with
modified May 27 "20 at 11:27

*

Itamar Mushkin
2,53722 gold badges1212 silver badges2929 bronze badges
asked Mar 11 "17 at 19:01
*

TaylrlTaylrl
2,64122 gold badges2626 silver badges3939 bronze badges
Include a remark|

2 Responses 2


Energetic Oldest Votes
99
This mistake is triggered by:

Y = Dataset.iloc <:,18> valuesIndexing runs out bounds right here most likely due to the fact that there are much less than 19 columns in your Dataset, so column 18 does not exist. The adhering to code you gave doesn"t usage Y in all, so you can simply comment out this line in the meantime.


Share
Boost this solution
Comply with
responded to Mar 11 "17 at 19:29
*

slonopotamslonopotam
1,4201212 silver badges1010 bronze badges
0
Include a remark|
19
When you index a row/column with a number that is bigger than the measurements of your dataframe, this occurs. For example, obtaining the eleventh column when you have just 3.

import pandas as pddf = pd.DataFrame( )You have 5 rows as well as 3 columns :

Call City Car0 Mark Lisbon Tesla1 Laura Montreal Audi2 Adam Lisbon Porsche3 Roger Berlin Ford4 Anna Glasgow HondaLet"s attempt to index the eleventh column (it doesn"t exist):

df.iloc <:, 10> # there is clearly no 11th column IndexError: solitary positional indexer is out-of-bounds

Keep in mind that df.iloc [you are a novice with Python [:, 10> would certainly describe the eleventh column.


Share
Enhance this response
Adhere to
modified Apr 20 "20 at 14:33
addressed Jan 4 "20 at 2:38
*

Nicolas GervaisNicolas Gervais
25k1111 gold badges7878 silver badges105105 bronze badges
Include a remark|

Your Response


Many thanks for adding a solution to Pile Overflow!

Please make sure to respond to the inquiry Supply information as well as share your research study!

However prevent ...

Requesting assistance, explanation, or replying to various other answers.Making declarations based upon point of view; back them up with referrals or individual experience.

To find out more, see our pointers on composing excellent solutions.


Draft conserved
Draft threw out

Subscribe or visit


Register making use of Google
Register utilizing Facebook
Register making use of Email as well as Password
Send

Article as a visitor


Call
Email Required, however never ever revealed


Article as a visitor


Call
Email

Called for, however never ever revealed


Message Your Response Discard

By clicking "Message Your Solution", you consent to our regards to solution, personal privacy plan as well as cookie plan


Not the solution you'& #x 27; re searching for? Surf various other inquiries identified python or ask your very own inquiry.


The Overflow Blog site
Included on Meta
Connected
4
Python iloc providing indexError: solitary positional indexer is out-of-bounds in straightforward for loophole
0
solitary positional indexer is out-of-bounds index mistake
-1
Mistake: '' float ' things is not subscriptable
0
I am attempting to include information to an existing PPT layout making use of the python-pptx bundle
0
IndexError: solitary positional indexer is out-of-bounds Fitbit Python
0
Solitary positional indexer is out-of-bounds mistake analysis from CSV
Relevant
1127
"Big information" process utilizing pandas
0
python offering "IndexError: solitary positional indexer is out-of-bounds"
0
solitary positional indexer is out-of-bounds index mistake
4
Python iloc offering indexError: solitary positional indexer is out-of-bounds in straightforward for loophole
0
Pandas Dataframe: IndexError: solitary positional indexer is out-of-bounds
Warm Network Questions much more warm inquiries

Inquiry feed
Register for RSS
Inquiry feed To sign up for this RSS feed, duplicate as well as paste this link right into your RSS visitor.


*

lang-py
Pile Overflow
Products
Business
Heap Exchange Network
website layout/ logo design © © 2021 Heap Exchange Inc; customer payments certified under cc by-sa. rev2021.10.28.40592


Pile Overflow functions finest with JavaScript allowed
*

Your personal privacy

By clicking "Approve all cookies", you concur Heap Exchange can keep cookies on your tool as well as reveal info based on our Cookie Plan.