Información de Fisher nivel nodo: Sitio Metztitlan

  • Dra. Melanie Kolb
  • M. en F. C. Gustavo Magallanes-Guijón
  • Dr. Oliver López-Corona
In [2]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import sys, os
import datetime
from matplotlib.pylab import rcParams
%matplotlib inline
import warnings
import seaborn as sns
import functools 
In [3]:
!ls *.csv > lista.txt
In [4]:
lista = pd.read_csv('lista.txt', header = None)
list_of_rows = [j for j in lista.values]
# Print list of lists i.e. rows
len(list_of_rows)
Out[4]:
40
In [5]:
filesnames = os.listdir()
filesnames = [f for f in filesnames if (f.endswith(".csv"))]
In [6]:
dfs = list()
string = "_df"
for filename in filesnames:
    #print(filename)
    #nueva = string.join(filename)
    df = pd.read_csv(filename)
    dfs.append(df)    
In [9]:
merged = pd.merge(dfs[0], dfs[1])
#for i in range(len(dfs)):
for i in range(len(dfs)):
    merged = pd.merge(merged, dfs[i])
In [ ]:
 
In [10]:
merged
Out[10]:
473.0 20.3333 0.1646 0.0003 301.0 0.5155 7.85 0.0179 0.9534 10462.0 ... 40.0 10.0 0.17657143 0.0003432 0.4332 0.016157143 0.7268 187.5 2012-12-05 193.466

0 rows × 39 columns

In [61]:
merged = pd.merge(dfs[0], dfs[1])
In [97]:
merged = pd.merge(merged, dfs[39]) #13, 38
merged
Out[97]:
2012-12-05 473.0 20.3333 0.1646 0.0003 301.0 0.5155 7.85 0.0179 0.9534 ... 0.0864 36.0 40.0 10.0 0.17657143 0.0003432 0.4332 0.016157143 0.7268 193.466
0 2014-08-12 246.0 23.8 0.097000 0.000160 1723.0 0.445000 8.0 0.039000 1.158000 ... 0.072000 50.00 77.5 20.000000 0.030000 0.000110 1.256000 0.004400 1.943000 160.00
1 2015-06-16 323.0 25.8 0.097999 0.000155 10.0 0.096172 7.8 0.002875 0.755858 ... 0.053206 42.00 25.0 104.500000 0.018667 0.000148 0.037583 0.004900 0.618837 199.61
2 2015-09-13 774.0 22.1 0.096771 0.000069 5475.0 0.104798 7.7 0.030934 0.753085 ... 0.035550 54.00 55.0 189.000000 0.022000 0.000096 1.166088 0.034700 1.853759 82.51
3 2016-03-05 426.0 22.3 0.032482 0.000374 31.0 0.042899 8.4 0.016863 0.975848 ... 0.171312 64.00 36.0 129.333330 0.024000 0.000206 0.049949 0.005800 0.922659 204.34
4 2016-09-18 794.0 23.6 0.112780 0.000100 52.0 0.163656 7.9 0.045480 1.275159 ... 0.036990 30.00 30.0 69.666664 0.063000 0.000104 0.824911 0.086092 1.368339 152.64
5 2018-02-11 530.0 20.7 0.151770 0.000096 74.0 0.198454 8.1 0.026406 0.853729 ... 0.062647 34.00 30.0 30.000000 0.110000 0.000065 0.487336 0.008300 0.863120 222.72
6 2019-02-15 265.0 23.5 0.026774 0.000044 20.0 0.071418 8.5 0.002813 0.627657 ... 0.036650 27.74 20.0 41.000000 0.053000 0.000044 0.008934 0.007337 0.930861 202.77

7 rows × 39 columns

In [98]:
from sklearn import preprocessing

df_num = merged.select_dtypes(include=[np.number])

x = df_num.values #returns a numpy array
min_max_scaler = preprocessing.MinMaxScaler()
x_scaled = min_max_scaler.fit_transform(x)
df_num = pd.DataFrame(x_scaled)
df_num
Out[98]:
0 1 2 3 4 5 6 7 8 9 ... 28 29 30 31 32 33 34 35 36 37
0 0.000000 0.607843 0.561826 0.351515 0.313449 1.000000 0.375 0.848126 0.819060 1.000000 ... 0.268485 0.613900 1.000000 0.000000 0.124088 0.408624 1.000000 0.000000 1.000000 0.552671
1 0.140511 1.000000 0.569818 0.336364 0.000000 0.132487 0.125 0.001453 0.197993 0.098008 ... 0.130051 0.393271 0.086957 0.500000 0.000000 0.642710 0.022973 0.006121 0.000000 0.835176
2 0.963504 0.274510 0.559994 0.075758 1.000000 0.153939 0.000 0.659081 0.193711 0.770211 ... 0.000000 0.724214 0.608696 1.000000 0.036496 0.322382 0.927901 0.370907 0.932606 0.000000
3 0.328467 0.313725 0.045665 1.000000 0.003843 0.000000 0.875 0.329294 0.537745 0.000000 ... 1.000000 1.000000 0.278261 0.646943 0.058394 1.000000 0.032889 0.017138 0.229445 0.868911
4 1.000000 0.568627 0.688070 0.169697 0.007685 0.300315 0.250 1.000000 1.000000 0.409868 ... 0.010607 0.062328 0.173913 0.293886 0.485401 0.371663 0.654317 1.000000 0.566019 0.500178
5 0.518248 0.000000 1.000000 0.157576 0.011711 0.386856 0.500 0.552957 0.349145 0.001348 ... 0.199592 0.172642 0.173913 0.059172 1.000000 0.131417 0.383622 0.047740 0.184481 1.000000
6 0.034672 0.549020 0.000000 0.000000 0.001830 0.070925 1.000 0.000000 0.000000 0.804291 ... 0.008102 0.000000 0.000000 0.124260 0.375912 0.000000 0.000000 0.035954 0.235639 0.857713

7 rows × 38 columns

In [99]:
result = pd.concat([merged.select_dtypes(np.object), df_num], axis=1)
result
Out[99]:
2012-12-05 0 1 2 3 4 5 6 7 8 ... 28 29 30 31 32 33 34 35 36 37
0 2014-08-12 0.000000 0.607843 0.561826 0.351515 0.313449 1.000000 0.375 0.848126 0.819060 ... 0.268485 0.613900 1.000000 0.000000 0.124088 0.408624 1.000000 0.000000 1.000000 0.552671
1 2015-06-16 0.140511 1.000000 0.569818 0.336364 0.000000 0.132487 0.125 0.001453 0.197993 ... 0.130051 0.393271 0.086957 0.500000 0.000000 0.642710 0.022973 0.006121 0.000000 0.835176
2 2015-09-13 0.963504 0.274510 0.559994 0.075758 1.000000 0.153939 0.000 0.659081 0.193711 ... 0.000000 0.724214 0.608696 1.000000 0.036496 0.322382 0.927901 0.370907 0.932606 0.000000
3 2016-03-05 0.328467 0.313725 0.045665 1.000000 0.003843 0.000000 0.875 0.329294 0.537745 ... 1.000000 1.000000 0.278261 0.646943 0.058394 1.000000 0.032889 0.017138 0.229445 0.868911
4 2016-09-18 1.000000 0.568627 0.688070 0.169697 0.007685 0.300315 0.250 1.000000 1.000000 ... 0.010607 0.062328 0.173913 0.293886 0.485401 0.371663 0.654317 1.000000 0.566019 0.500178
5 2018-02-11 0.518248 0.000000 1.000000 0.157576 0.011711 0.386856 0.500 0.552957 0.349145 ... 0.199592 0.172642 0.173913 0.059172 1.000000 0.131417 0.383622 0.047740 0.184481 1.000000
6 2019-02-15 0.034672 0.549020 0.000000 0.000000 0.001830 0.070925 1.000 0.000000 0.000000 ... 0.008102 0.000000 0.000000 0.124260 0.375912 0.000000 0.000000 0.035954 0.235639 0.857713

7 rows × 39 columns

In [100]:
result.to_csv("master.csv",index=False, header=False)
In [101]:
os.chdir("fisher-nodo/")
In [102]:
fs = !ls *.png

import IPython.display as dp

# create list of image objects
images = []
for ea in fs:
    images.append(dp.Image(filename=ea, format='png'))

# display all images
for ea in images:
    dp.display_png(ea)