-1

This should be easy, and it probably is, but.. I'm reading DataFrame and want to out put records into an array I can manipulate.

All the elements of the array are strings and essentially what I want to do is append each line from this DataFrame, ( based on the DEP number and other conditions).

I'm trying to process the data frame by DEP number, by putting all DEP numbers in the DataFrame, with the same value,(that meet other conditions) into a separate array. Then I process the array.

This is not a straight conversion of a data frame into a numpy array

DEP      POSITION    FNAME   LNAME
dept1    positiona   fname1  lname1
dept1    positionb   fname2  lname2
dept1    positionc   fname1  lname1
dept1    positiond   fname4  lname4
dept2    position2   fname2  lname2
dept3    position3   fname3  lname3
dept4    position4   fname4  lname4


dept1    positiona   fname1  lname1
dept1    positionc   fname1  lname1

I've tried using numpy without success

i=0
MYArray=np.empty((0,4),str)
while i < len[df.index]
    MYarray=np.append(MYArray,(df['DEP'][i],df['POSITION'][i],df['FNAME'][i],df['POSITION'][i]),axis=0)
C0ppert0p
  • 634
  • 2
  • 7
  • 23

1 Answers1

0

use df.values to get all your dataframe into array

Eliethesaiyan
  • 2,327
  • 1
  • 22
  • 35