0

I have an unlabeled dataset which contains 101 columns i.e. no column have any heading, now I want to start reading from column 2 to end i.e. 101th column. I am trying with this code :

data = np.loadtxt('structure-safety.inp', usecols = [2, 101])
or 
data = pd.read_fwf('structure-safety.inp', usecols = [2,1,101])

I also tried with usecols = [2, :], [2:101] or used () instead of [] but in vain, can anyone help me here with this problem.

1 Answer 1

1

Try:

data = pd.read_fwf('structure-safety.inp', usecols=list(range(2,102))

Keep in mind that the columns are numbered from 0. So column 2 is actually the third column.

Or you can drop a column:

data = pd.read_fwf('structure-safety.inp')
data = data.drop(df.columns[0:2], axis=1)
Sign up to request clarification or add additional context in comments.

1 Comment

You may be better off just dropping a column then. See the edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.