Pull data from MySQL database into a pandas Dataframe

First, please specify a local directory where we can save the data to.


In [1]:
%cd /Users/elizabethasmith/Desktop/sql


/Users/elizabethasmith/Desktop/sql

The script 'getSQLdata.py' will pull data from the MySQL database using the following syntax:

%run getSQLdata.py SXT_datamatrix.Mouse_Cells_ALL;

If you successfully pull data, you will get a notification summary.


In [3]:
%run getSQLdata.py SXT_datamatrix Mouse_Cells_ALL;


Retrieving data from the Mouse_Cells_ALL; table from the SXT_datamatrix My SQL database...
 
Success!  You just pulled out 26 rows, each of which contained 39 columns, of data.

You also pulled out 39 field names.

These data have been saved in a pandas Dataframe called SXT_datamatrix_Mouse_Cells_ALL;_2015-01-05_12-48-32.npy locally at /Users/elizabethasmith/Desktop/sql.

The Dataframe is also present as a global variable called "df".

Check that this is the data you are intending to pull by displaying the data as a table.


In [5]:
df


Out[5]:
idMouse_Cells_ CellType Volume_of_Nucleus_(um^3) Volume_of_ECR_(um^3) Volume_of_HCR_(µm^3) Volume_of_Nucleoli_(µm^3) %_Nuclear_Volume_ECR %_Nuclear_Volume_HCR %_Nuclear_Volume_Nucleoli Surface_Area_Nuclear_Envelope_(µm^2) ... Polarity_of_HCR_(µm) Mean_Radius_of_HCR_(µm) Max_Radius_of_HCR_(µm ) Complexity_HCR_Skeleton Fractal_Dimension_of_HCR Error_Fractal_Dimension_of_HCR Fractal_Dimension_of_Nucleus Error_Fractal_Dimension_of_Nucleus %_HCR_Central %_HCR_Peripheral
0 2 B-Lymphocyte 66.3449 27.2668 39.0780 0.784957 41.0986 58.9014 1.183150 83.6144 ... 0.145258 0.484488 0.96 9013 2.71135 0.295190 2.57205 0.219156 68.63620 0.738725
1 4 cancer 383.7490 305.1100 78.6396 42.853100 79.5076 20.4924 11.167000 346.9600 ... 1.281950 0.168585 0.36 14080 2.78040 0.188539 2.28234 0.134772 5.53197 0.501269
2 2 B-Lymphocyte 66.3449 27.2668 39.0780 0.784957 41.0986 58.9014 1.183150 83.6144 ... 0.145258 0.484488 0.96 9013 2.71135 0.295190 2.57205 0.219156 68.63620 0.738725
3 2 B-Lymphocyte 170.1640 76.9439 93.2197 0.427622 45.2176 54.7824 0.251301 164.0300 ... 0.125474 0.302631 0.60 56449 2.79671 0.197425 2.63880 0.122275 57.08800 0.759885
4 2 B-Lymphocyte 74.4857 33.2654 41.2203 1.000310 44.6601 55.3399 1.342950 92.5136 ... 0.235226 0.383058 0.84 7294 2.73169 0.268770 2.57514 0.197709 38.48460 0.802155
5 2 B-Lymphocyte 83.9752 37.6468 46.3284 1.685450 44.8309 55.1691 2.007090 102.2480 ... 0.140074 0.310424 0.66 9351 2.74968 0.247996 2.59137 0.170459 26.80100 0.887208
6 2 B-Lymphocyte 87.8655 44.2304 43.6351 0.363561 50.3388 49.6612 0.413770 98.1634 ... 0.050914 0.301871 0.66 10063 2.77685 0.213452 2.59283 0.132897 28.77840 0.832397
7 2 B-Lymphocyte 99.4286 46.2350 53.1936 0.895058 46.5007 53.4993 0.900201 106.7120 ... 0.076018 0.297503 0.60 11537 2.80457 0.158139 2.63822 0.090558 30.13090 0.888489
8 2 B-Lymphocyte 83.6783 39.8066 43.8717 1.452340 47.5710 52.4290 1.735630 95.3044 ... 0.053029 0.292899 0.54 7831 2.75285 0.248884 2.58352 0.172264 21.42560 0.856311
9 2 B-Lymphocyte 82.1372 34.3073 47.8298 0.793805 41.7683 58.2317 0.966438 92.9574 ... 0.200282 0.406702 0.78 8003 2.76087 0.236026 2.61979 0.171701 36.97100 0.857541
10 2 B-Lymphocyte 83.1241 39.2170 43.9071 0.940179 47.1789 52.8211 1.131050 93.7042 ... 0.214126 0.315426 0.66 8809 2.75842 0.235090 2.59142 0.157562 25.79490 0.804309
11 2 B-Lymphocyte 81.4445 37.7457 43.6988 1.175320 46.3452 53.6548 1.443100 93.5608 ... 0.184324 0.322724 0.66 8192 2.76282 0.232276 2.59804 0.158318 24.40790 0.861210
12 2 B-Lymphocyte 182.9390 87.0021 95.9371 6.005490 47.5579 52.4421 3.282780 176.4970 ... 0.057729 0.224031 0.48 39205 2.80072 0.192027 2.61727 0.091056 52.18690 0.781224
13 2 B-Lymphocyte 81.4760 39.9664 41.5097 0.335872 49.0529 50.9471 0.412234 94.5835 ... 0.059173 0.326499 0.72 9617 2.75482 0.227982 2.58084 0.150269 32.89930 0.737986
14 2 B-Lymphocyte 169.9990 75.3618 94.6377 3.038480 44.3306 55.6694 1.787350 186.1500 ... 0.157061 0.220230 0.42 36269 2.77015 0.225247 2.60809 0.141621 37.32130 0.889454
15 2 B-Lymphocyte 89.6586 38.8897 50.7689 0.409534 43.3753 56.6247 0.456771 100.5050 ... 0.115619 0.381315 0.90 11981 2.74048 0.266501 2.58886 0.189717 70.47850 0.894204
16 4 cancer 383.7490 305.1100 78.6396 42.853100 79.5076 20.4924 11.167000 346.9600 ... 1.281950 0.168585 0.36 14080 2.78040 0.188539 2.28234 0.134772 5.53197 0.501269
17 4 cancer 487.6410 372.6610 114.9800 49.294100 76.4212 23.5788 10.108700 368.5860 ... 0.935590 0.131836 0.30 14356 2.78148 0.212586 2.27016 0.138213 7.02035 0.649011
18 4 cancer 564.9000 424.9080 139.9920 65.026700 75.2183 24.7817 11.511200 433.0470 ... 0.577048 0.138134 0.42 21151 2.79645 0.187166 2.32407 0.135948 14.32380 0.670322
19 4 cancer 426.3120 335.1450 91.1672 48.250300 78.6149 21.3851 11.318100 401.5500 ... 0.958430 0.128145 0.36 14739 2.74686 0.238286 2.24878 0.058154 11.69410 0.541978
20 4 cancer 538.9410 420.8060 118.1350 65.086100 78.0802 21.9198 12.076700 441.6120 ... 0.888652 0.142342 0.36 17525 2.77401 0.212259 2.28357 0.100752 8.92096 0.602442
21 4 cancer 395.7650 292.8780 102.8860 49.395000 74.0032 25.9969 12.480900 323.6970 ... 0.314256 0.137923 0.36 17498 2.79919 0.168569 2.33824 0.129106 16.62110 0.647063
22 4 cancer 240.1110 175.3480 64.7631 20.242400 73.0279 26.9721 8.430430 264.0230 ... 0.550396 0.147141 0.42 21622 2.77532 0.191421 2.31954 0.131400 18.06150 0.511723
23 4 cancer 429.3920 351.0900 78.3012 48.550400 81.7646 18.2354 11.306800 388.7100 ... 0.554938 0.111849 0.24 12949 2.77590 0.193416 2.19149 0.151996 6.21968 0.426768
24 4 cancer 502.3070 417.0520 85.2556 50.418400 83.0272 16.9728 10.037400 384.8480 ... 1.737040 0.148494 0.30 16608 2.78499 0.203592 2.24298 0.080180 8.41715 0.531860
25 4 cancer 445.8060 375.8240 69.9819 62.807400 84.3022 15.6978 14.088500 454.5160 ... 0.692527 0.127219 0.36 11365 2.73899 0.237241 2.13696 0.149920 10.35420 0.339770

26 rows × 39 columns


In [ ]: