Code changing rder of headers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Code changing rder of headers (/thread-37720.html) |
Code changing rder of headers - Led_Zeppelin - Jul-13-2022 I am working with the following output when using a Python3 program. Unnamed: 0 timestamp time_period sensor_00 sensor_01 sensor_02 sensor_03 sensor_04 sensor_05 sensor_06 sensor_07 sensor_08 sensor_09 sensor_10 sensor_11 sensor_12 sensor_13 sensor_14 sensor_15 sensor_16 sensor_17 sensor_18 sensor_19 sensor_20 sensor_21 sensor_22 sensor_23 sensor_24 sensor_25 sensor_26 sensor_27 sensor_28 sensor_29 sensor_30 sensor_31 sensor_32 sensor_33 sensor_34 sensor_35 sensor_36 sensor_37 sensor_38 sensor_39 sensor_40 sensor_41 sensor_42 sensor_43 sensor_44 sensor_45 sensor_46 sensor_47 sensor_48 sensor_49 sensor_50 sensor_51 machine_status 0 0 2018-04-01 00:00:00 Night 2.465394 47.09201 53.2118 46.310760 634.3750 76.45975 13.41146 16.13136 15.56713 15.05353 37.22740 47.52422 31.11716 1.681353 419.5747 NaN 461.8781 466.3284 2.565284 665.3993 398.9862 880.0001 498.8926 975.9409 627.6740 741.7151 848.0708 429.0377 785.1935 684.9443 594.4445 682.8125 680.4416 433.7037 171.9375 341.9039 195.0655 90.32386 40.36458 31.51042 70.57291 30.98958 31.770832 41.92708 39.641200 65.68287 50.92593 38.194440 157.9861 67.70834 243.0556 201.3889 NORMAL 1 1 2018-04-01 00:01:00 Night 2.465394 47.09201 53.2118 46.310760 634.3750 76.45975 13.41146 16.13136 15.56713 15.05353 37.22740 47.52422 31.11716 1.681353 419.5747 NaN 461.8781 466.3284 2.565284 665.3993 398.9862 880.0001 498.8926 975.9409 627.6740 741.7151 848.0708 429.0377 785.1935 684.9443 594.4445 682.8125 680.4416 433.7037 171.9375 341.9039 195.0655 90.32386 40.36458 31.51042 70.57291 30.98958 31.770832 41.92708 39.641200 65.68287 50.92593 38.194440 157.9861 67.70834 243.0556 201.3889 NORMAL 2 2 2018-04-01 00:02:00 Night 2.444734 47.35243 53.2118 46.397570 638.8889 73.54598 13.32465 16.03733 15.61777 15.01013 37.86777 48.17723 32.08894 1.708474 420.8480 NaN 462.7798 459.6364 2.500062 666.2234 399.9418 880.4237 501.3617 982.7342 631.1326 740.8031 849.8997 454.2390 778.5734 715.6266 661.5740 721.8750 694.7721 441.2635 169.9820 343.1955 200.9694 93.90508 41.40625 31.25000 69.53125 30.46875 31.770830 41.66666 39.351852 65.39352 51.21528 38.194443 155.9606 67.12963 241.3194 203.7037 NORMAL 3 3 2018-04-01 00:03:00 Night 2.460474 47.09201 53.1684 46.397568 628.1250 76.98898 13.31742 16.24711 15.69734 15.08247 38.57977 48.65607 31.67221 1.579427 420.7494 NaN 462.8980 460.8858 2.509521 666.0114 399.1046 878.8917 499.0430 977.7520 625.4076 739.2722 847.7579 474.8731 779.5091 690.4011 686.1111 754.6875 683.3831 446.2493 166.4987 343.9586 193.1689 101.04060 41.92708 31.51042 72.13541 30.46875 31.510420 40.88541 39.062500 64.81481 51.21528 38.194440 155.9606 66.84028 240.4514 203.1250 NORMAL 4 4 2018-04-01 00:04:00 Night 2.445718 47.13541 53.2118 46.397568 636.4583 76.58897 13.35359 16.21094 15.69734 15.08247 39.48939 49.06298 31.95202 1.683831 419.8926 NaN 461.4906 468.2206 2.604785 663.2111 400.5426 882.5874 498.5383 979.5755 627.1830 737.6033 846.9182 408.8159 785.2307 704.6937 631.4814 766.1458 702.4431 433.9081 164.7498 339.9630 193.8770 101.70380 42.70833 31.51042 76.82291 30.98958 31.510420 41.40625 38.773150 65.10416 51.79398 38.773150 158.2755 66.55093 242.1875 201.3889 NORMALThis output is correct. Sensor_15 should have no data at all. If you look through the columns, you can see that is the case. I then run the dataframe through the following code to normalize it and the scale it: scaler=StandardScaler() temp_df=scaler.fit_transform(df) df = pd.DataFrame(temp_df) df.head()Now the sensor I get the following output: 1.732043 0.221531 -0.151947 0.639367 1.057656 0.303417 0.177086 -0.043528 0.128859 0.178536 0.119982 -0.350879 0.429361 0.195788 -0.782050 0.377318 NaN 0.360152 0.349972 0.341435 0.374072 0.374420 0.369572 0.253027 0.182746 0.391879 0.419127 0.249973 -0.426732 -0.212400 0.481694 -0.102960 -0.636623 -0.475217 -0.349597 -0.713252 -0.601147 -1.375222 0.785445 -0.881503 -0.326638 0.080875 -0.553961 -0.358948 -0.176788 -0.260504 1.759525 0.185877 -0.588606 0.086292 0.553104 0.919519 -0.008859 1 -1.732027 0.221531 -0.151947 0.639367 1.057656 0.303417 0.177086 -0.043528 0.128859 0.178536 0.119982 -0.350879 0.429361 0.195788 -0.782050 0.377318 NaN 0.360152 0.349972 0.341435 0.374072 0.374420 0.369572 0.253027 0.182746 0.391879 0.419127 0.249973 -0.426732 -0.212400 0.481694 -0.102960 -0.636623 -0.475217 -0.349597 -0.713252 -0.601147 -1.375222 0.785445 -0.881503 -0.326638 0.080875 -0.553961 -0.358948 -0.176788 -0.260504 1.759525 0.185877 -0.588606 0.086292 0.553104 0.919519 -0.008859 2 -1.732011 0.170259 -0.072887 0.639367 1.093546 0.334759 0.008636 -0.084091 0.085614 0.203678 0.099020 -0.297925 0.479375 0.291872 -0.778120 0.388565 NaN 0.367304 0.298158 0.256276 0.378206 0.383791 0.371441 0.269006 0.206024 0.410851 0.414998 0.257387 -0.278335 -0.233546 0.617599 0.240016 -0.498857 -0.420227 -0.299450 -0.735379 -0.592037 -1.354820 0.880678 -0.782676 -0.343317 0.032133 -0.619901 -0.358948 -0.200367 -0.285498 1.736986 0.204376 -0.588605 0.061664 0.522874 0.892914 0.013040 3 -1.731996 0.209321 -0.151947 0.627530 1.093545 0.260019 0.207682 -0.087469 0.182094 0.243184 0.133959 -0.239048 0.516050 0.250668 -0.796818 0.387694 NaN 0.368242 0.307832 0.268627 0.377143 0.375581 0.364682 0.254000 0.188952 0.379447 0.408066 0.248704 -0.156831 -0.230557 0.505865 0.365381 -0.383135 -0.463929 -0.266377 -0.774794 -0.586654 -1.381776 1.070428 -0.733263 -0.326638 0.153987 -0.619901 -0.384330 -0.271105 -0.310494 1.691906 0.204376 -0.588606 0.061664 0.507759 0.879613 0.007566 4 -1.731980 0.172701 -0.138771 0.639367 1.093545 0.317882 0.184557 -0.070569 0.165459 0.243184 0.133959 -0.163830 0.547215 0.278334 -0.781691 0.380126 NaN 0.357078 0.364622 0.393011 0.363095 0.389682 0.380986 0.250734 0.195200 0.389186 0.400510 0.245300 -0.545808 -0.212281 0.569172 0.086268 -0.342724 -0.390791 -0.348241 -0.794583 -0.614837 -1.379329 1.088064 -0.659143 -0.326638 0.373326 -0.553961 -0.384330 -0.223946 -0.335489 1.714445 0.241374 -0.533186 0.089811 0.492644 0.906216 -0.008859Now it is sensor 16 or just 16 that is the column with no data. Now sensor 16 and not sensor 15 with no data. This makes no sense. All I am trying to do is scale and normalize the data. I had previously dropped all data columns that did not have numeric values. Those columns were "timestamp", "timeperiod" and "machine_status". They did not have numerical values in them so dropped them to get a dataframe with only numerical values. Then I scaled and normalized I wanted to normalize and scale. I did not want to move the numeric columns around. How do I fix this? Thanks in advance. Respectfully, LZ This issue/problem is described much better in my latest post. LZ |