3 Replies - 716 Views - Last Post: 01 March 2016 - 01:53 PM Rate Topic: -----

#1 roosnanie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-July 13

Error with python and pandas...

Posted 01 March 2016 - 09:48 AM

    def build_test_data_frame_high_BBn_or_BRnX(self):
        data = np.array([
            [parse('2016-02-13 18:15:35'), 1.548170, 1.075170, 1.548170, 1.0087170,  1.008170, 1.007170, 1.098170, 1.00170, 1.788170, 1.078170,  54, 99],
            [parse('2016-02-13 17:16:35'), 696, 286, 734,  19, 279, 122, 945, 129, 911, 823, 720, 99],
            [parse('2016-02-13 18:17:35'), 217, 975, 206, 865,  92, 157,  17, 158, 209, 621,  82, 175],
            [parse('2016-02-13 19:18:35'), 924, 281, 804, 611, 788, 443, 960, 856, 301, 269, 361, 848],
            [parse('2016-02-13 20:21:35'), 930, 266,  84,  44, 268, 358, 339, 623, 628, 249, 663, 319],
            [parse('2016-02-13 21:22:35'),  88, 250, 774, 164, 950, 578, 107, 359, 187, 447, 128, 944],
            [parse('2016-02-13 22:23:35'), 918, 726,  45, 107, 750, 711, 668, 796, 682, 317, 446, 797],
            [parse('2016-02-13 23:24:35'), 579, 926, 497, 733, 451, 844, 439, 478, 922, 738, 398, 380],
            [parse('2016-02-14 00:25:35'), 50, 881, 457, 144, 234, 530, 955, 490, 847, 259, 872,  81],
            [parse('2016-02-14 01:26:35'), 253, 956, 443, 577, 735,  74, 514, 456, 111, 895, 202, 188],
            [parse('2016-02-13 18:15:35'), 318, 132, 207, 893,  17, 697, 691, 260, 800, 462,  54, 99],
            [parse('2016-02-13 17:16:35'), 696, 286, 734,  19, 279, 122, 945, 129, 911, 823, 720, 99],
            [parse('2016-02-13 18:17:35'), 217, 975, 206, 865,  92, 157,  17, 158, 209, 621,  82, 175],
            [parse('2016-02-13 19:18:35'), 924, 281, 804, 611, 788, 443, 960, 856, 301, 269, 361, 848],
            [parse('2016-02-13 20:21:35'), 930, 266,  84,  44, 268, 358, 339, 623, 628, 249, 663, 319],
            [parse('2016-02-13 21:22:35'),  88, 250, 774, 164, 950, 578, 107, 359, 187, 447, 128, 944],
            [parse('2016-02-13 22:23:35'), 918, 726,  45, 107, 750, 711, 668, 796, 682, 317, 446, 797],
            [parse('2016-02-13 23:24:35'), 579, 926, 497, 733, 451, 844, 439, 478, 922, 738, 398, 380],
            [parse('2016-02-14 00:25:35'), 50, 881, 457, 144, 234, 530, 955, 490, 847, 259, 872,  81]

         ])
        data_frame = pd.DataFrame(data, columns=['timestamp', 'BTJ1_1', 'BTJ1_2', 'BTJ2_1', 'BTJ2_2', 'BTJ3_1', 'BTJ3_2', 'BTGJ1_1', 'BTGJ1_2', 'BTGJ2_1', 'BTGJ2_2', 'LTTH1', 'TNH'])
        return data_frame

    def test_high_BBn_or_BRnX(self):
        df = self.build_test_data_frame_high_BBn_or_BRnX()
        modified_df = high_BBn_or_BRnX(df)

        self.assertEqual(modified_df.ix[0]['BTJ1_1_HBB_SOI'], 1)


that is my code.. and this is my error..
    self.assertEqual(modified_df.ix[1]['BTJ1_1_HBB_SOI'], 1)
  File "/Users/superkewlusername/Envs/core/lib/python2.7/site-packages/pandas/core/series.py", line 521, in __getitem__
    result = self.index.get_value(self, key)
  File "/Users/superkewlusername/Envs/core/lib/python2.7/site-packages/pandas/core/index.py", line 1609, in get_value
    raise e1
KeyError: 'BTJ1_1_HBB_SOI'



Im pretty much an entry level developer .. learning as i go.. I have searched the error but am still not finding how to get this corrected in a timely manner.. any help is greatly appreciated.. thank in advance..

This post has been edited by modi123_1: 01 March 2016 - 10:05 AM
Reason for edit:: Removed user's name..


Is This A Good Question/Topic? 0
  • +

Replies To: Error with python and pandas...

#2 andrewsw  Icon User is offline

  • say what now
  • member icon

Reputation: 6409
  • View blog
  • Posts: 25,892
  • Joined: 12-December 12

Re: Error with python and pandas...

Posted 01 March 2016 - 09:53 AM

This isn't a discussion topic, just a problem. Moved out of Discussion Lounge.
Was This Post Helpful? 0
  • +
  • -

#3 roosnanie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-July 13

Re: Error with python and pandas...

Posted 01 March 2016 - 01:50 PM

View Postandrewsw, on 01 March 2016 - 09:53 AM, said:

This isn't a discussion topic, just a problem. Moved out of Discussion Lounge.

How do i just delete this ...
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13554
  • View blog
  • Posts: 54,094
  • Joined: 12-June 08

Re: Error with python and pandas...

Posted 01 March 2016 - 01:53 PM

Per the rules we don't delete topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1