1

I'm working with a feature set structured like the following, which has 150 features:

-1 45:1 55:1 67:1
1  55:1 65:1 89:1

How can I use pandas to expand this data set such that it's a full matrix or array with all 150 features? In other words in the first row feature 44 is 0, so I would like to use pandas to make something like:

[-1,0,0,0,...(44th entry)0,1,...
1,0,0,0,...(54th entry)0,1,...]

Basically I assume there is a way in pandas to do this so I don't write a for loop and generate a zeros matrix and have it fill in the values. Am I seeking to do something like this : Fill a Pandas dataframe using information from another Pandas dataframe Or is there a better implementation since my problem seems less complex. Thanks as I am new to pandas.

2
  • I don't understand how your input data is structured, what type of object is that? Are the -1 and 1 at the beginning supposed to be indices? Commented Jan 21, 2016 at 19:57
  • no they are binary classifiers or imagine a matrix like [y|x1 x2 x3,...] Commented Jan 22, 2016 at 1:52

1 Answer 1

0

Turns out the data was in svm_light format so I used the approbate python module - problem solved!

Sign up to request clarification or add additional context in comments.

Comments

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.