0

i have below dataframe belows .. and i wanna convert it to numpy array. when i tried.. time order is broken converted to numpy array. may it's because it is time-series data (19:00~0:00:00~07:00:00)

how can i keep time-order convert dataframe to numpy array?

        aaa                                                         \
Date     2015-12-06 2015-12-13 2015-12-20 2015-12-23 2015-12-26 2016-01-03   
Time                                                                         
19:00:00       4.72       8.50       3.87       7.95       1.76       9.82   
19:15:00       4.54       8.00       3.72       8.14       1.74       9.77   
19:30:00       4.44       8.17       3.72       7.99       1.75       9.77   
19:45:00       4.37       7.92       3.28       7.94       1.89       9.61   
20:00:00       4.03       7.54       2.48       7.99       1.98       9.46   
20:15:00       3.74       7.86       3.30       7.68       1.63       9.30   
20:30:00       3.48       8.41       3.52       7.88       1.52       9.22   
20:45:00       3.31       8.52       3.81       7.83       1.54       9.08   
21:00:00       3.17       8.23       3.97       7.96       1.63       9.14   
21:15:00       2.99       8.23       3.37       7.61       1.87       9.14   
21:30:00       2.96       8.26       3.23       7.63       2.03       9.13   
21:45:00       2.69       7.89       3.10       7.34       2.12       9.04   
22:00:00       2.62       7.83       2.94       7.21       2.11       9.04   
22:15:00       2.55       7.78       2.83       7.26       2.39       9.01   
22:30:00       2.49       7.73       2.89       7.15       2.30       9.08   
22:45:00       2.48       7.80       2.79       7.02       2.22       8.92   
23:00:00       2.38       7.71       2.92       7.17       2.43       8.80   
23:15:00       2.23       7.74       3.01       7.24       2.33       8.56   
23:30:00       2.29       7.51       3.10       7.14       2.38       8.32   
23:45:00       2.29       7.31       3.00       6.89       2.10       8.02   
00:00:00       2.17       6.84       2.84       6.89       1.82       7.86   
00:15:00       2.13       6.84       2.65       7.06       1.36       7.95   
00:30:00       2.21       6.78       2.63       6.98       0.92       7.97   
00:45:00       2.19       6.41       2.18       7.08       1.05       7.80   
01:00:00       2.13       6.24       1.56       7.20       0.81       7.73   
01:15:00       2.14       5.90       1.39       7.31       1.01       7.89   
01:30:00       2.13       5.74       1.81       7.58       0.79       7.91   
01:45:00       2.11       5.82       1.60       7.47       1.19       8.02   
02:00:00       1.72       6.01       0.90       7.14       1.27       8.09   
02:15:00       1.94       6.04       1.12       7.33       0.95       8.13   
02:30:00       2.05       6.00       1.44       7.06       1.15       8.15   
02:45:00       1.96       6.03       1.45       6.86       1.05       7.95   
03:00:00       1.63       6.28       1.62       6.85       1.22       7.43   
03:15:00       1.79       6.14       1.41       6.94       1.05       6.97   
03:30:00       1.37       6.03       1.29       6.98       1.27       6.97   
03:45:00       1.44       5.84       1.01       7.29       1.31       6.90   
04:00:00       1.37       5.62       0.92       7.13       1.35       6.77   
04:15:00       1.62       5.75       0.95       7.18       1.21       7.09   
04:30:00       1.64       5.71       1.06       7.18       1.32       7.27   
04:45:00       1.40       5.46       0.79       7.17       1.55       7.35   
05:00:00       1.51       5.48       0.64       6.83       1.42       7.27   
05:15:00       1.46       5.80       0.52       6.58       1.60       7.21   
05:30:00       1.61       5.59       0.35       6.98       1.54       7.13   
05:45:00       1.49       5.28       0.46       6.58       1.58       7.04   
06:00:00       1.55       5.00       0.17       6.35       1.88       7.10   
06:15:00       1.94       4.94      -0.18       6.12       1.94       7.11   
06:30:00       1.45       5.01      -0.31       6.02       1.90       7.14   
06:45:00       1.36       4.90      -0.17       5.83       2.06       7.17   
07:00:00       1.25       4.75       0.20       5.70       2.35       7.18 
6
  • 1
    Can you explain more? I test arr = df.values and it working nice. Commented Feb 7, 2018 at 6:51
  • when i convert it numpy & reshape as same with dataframe then numbers order is broken .. when you see 12-06 "4.72,4.54,4.44..." but converted is "4.72 8.5 3.87 .." i used "x=df.values" command Commented Feb 7, 2018 at 6:59
  • Do you need arr = df.values.T or arr = df.T.values ? Commented Feb 7, 2018 at 7:01
  • arr = df.values.T then no problem... i don't why i use .T .. anyway it's solved thanks Commented Feb 7, 2018 at 7:15
  • @jezrael - what's best to do in this situation, should you leave that as an answer so it can be marked as solved? Commented Feb 7, 2018 at 9:20

1 Answer 1

1

You need transpose DataFrame by T and convert to array:

arr = df.T.values

Or first convert to array and then transpose:

arr = df.values.T
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.