Información de Fisher nivel nodo: Metztitlán 2

  • 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]:
10
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 [8]:
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 [9]:
merged
Out[9]:
2012-12-05 0.5155 0.9534 37.0 0.004 352.0 170.08 0.0282 36.0 0.0003432 187.5
0 2013-04-17 0.054300 0.841600 51.0 0.003000 663.0 247.1072 0.072200 80.00 0.000400 37.5
1 2013-07-29 0.053000 1.194600 54.0 0.020100 262.0 168.6610 0.063400 74.00 0.000600 50.0
2 2014-04-03 0.107000 0.697000 38.0 0.002000 1236.0 222.3000 0.218000 50.00 0.000310 15.0
3 2014-08-12 0.445000 1.158000 85.0 0.017000 282.0 146.0000 0.156000 50.00 0.000110 75.0
4 2015-06-16 0.096172 0.755858 25.0 0.002798 98.0 193.8000 0.055934 42.00 0.000148 30.0
5 2015-09-13 0.104798 0.753085 30.0 0.007603 301.0 165.0200 0.036198 54.00 0.000096 30.0
6 2016-03-05 0.042899 0.975848 35.0 0.002440 98.0 200.2100 0.290231 64.00 0.000206 30.0
7 2016-09-18 0.163656 1.275159 30.0 0.002132 568.0 134.3200 0.041521 30.00 0.000104 40.0
8 2017-03-15 0.180371 1.297000 31.0 0.003491 135.0 220.5000 0.110372 32.00 0.000853 50.0
9 2018-02-11 0.198454 0.853729 24.0 0.023360 605.0 222.7200 0.080838 34.00 0.000065 18.0
10 2018-08-09 0.026042 1.162524 60.0 0.002286 189.0 202.4200 0.064808 62.86 0.000156 70.0
11 2018-10-27 0.331278 1.204825 33.0 0.008458 160.0 164.7700 0.081437 39.00 0.000076 40.0
12 2019-02-15 0.071418 0.627657 18.0 0.025164 20.0 194.7400 0.026275 27.74 0.000044 30.0
In [10]:
merged = pd.merge(dfs[0], dfs[1])
In [18]:
merged = pd.merge(merged, dfs[9])
merged
Out[18]:
2012-12-05 0.5155 0.9534 37.0 0.004 352.0 170.08 0.0282 36.0 0.0003432 187.5
0 2013-04-17 0.054300 0.841600 51.0 0.003000 663.0 247.1072 0.072200 80.00 0.000400 37.5
1 2013-07-29 0.053000 1.194600 54.0 0.020100 262.0 168.6610 0.063400 74.00 0.000600 50.0
2 2014-04-03 0.107000 0.697000 38.0 0.002000 1236.0 222.3000 0.218000 50.00 0.000310 15.0
3 2014-08-12 0.445000 1.158000 85.0 0.017000 282.0 146.0000 0.156000 50.00 0.000110 75.0
4 2015-06-16 0.096172 0.755858 25.0 0.002798 98.0 193.8000 0.055934 42.00 0.000148 30.0
5 2015-09-13 0.104798 0.753085 30.0 0.007603 301.0 165.0200 0.036198 54.00 0.000096 30.0
6 2016-03-05 0.042899 0.975848 35.0 0.002440 98.0 200.2100 0.290231 64.00 0.000206 30.0
7 2016-09-18 0.163656 1.275159 30.0 0.002132 568.0 134.3200 0.041521 30.00 0.000104 40.0
8 2017-03-15 0.180371 1.297000 31.0 0.003491 135.0 220.5000 0.110372 32.00 0.000853 50.0
9 2018-02-11 0.198454 0.853729 24.0 0.023360 605.0 222.7200 0.080838 34.00 0.000065 18.0
10 2018-08-09 0.026042 1.162524 60.0 0.002286 189.0 202.4200 0.064808 62.86 0.000156 70.0
11 2018-10-27 0.331278 1.204825 33.0 0.008458 160.0 164.7700 0.081437 39.00 0.000076 40.0
12 2019-02-15 0.071418 0.627657 18.0 0.025164 20.0 194.7400 0.026275 27.74 0.000044 30.0
In [19]:
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[19]:
0 1 2 3 4 5 6 7 8 9
0 0.067448 0.319631 0.492537 0.043170 0.528783 1.000000 0.173987 1.000000 0.440280 0.375000
1 0.064345 0.847014 0.537313 0.781385 0.199013 0.304476 0.140648 0.885189 0.687397 0.583333
2 0.193237 0.103599 0.298507 0.000000 1.000000 0.780053 0.726352 0.425947 0.329077 0.000000
3 1.000000 0.792334 1.000000 0.647557 0.215461 0.103558 0.491464 0.425947 0.081960 1.000000
4 0.167391 0.191533 0.104478 0.034450 0.064145 0.527365 0.112363 0.272866 0.128913 0.250000
5 0.187981 0.187390 0.179104 0.241884 0.231086 0.272194 0.037593 0.502488 0.064662 0.250000
6 0.040236 0.520198 0.253731 0.018995 0.064145 0.584197 1.000000 0.693838 0.200577 0.250000
7 0.328467 0.967369 0.179104 0.005698 0.450658 0.000000 0.057760 0.043245 0.074547 0.416667
8 0.368364 1.000000 0.194030 0.064367 0.094572 0.764094 0.318602 0.081515 1.000000 0.583333
9 0.411526 0.337752 0.089552 0.922121 0.481086 0.783777 0.206712 0.119786 0.026359 0.050000
10 0.000000 0.799093 0.626866 0.012347 0.138980 0.603792 0.145983 0.672024 0.138797 0.916667
11 0.728560 0.862290 0.223881 0.278795 0.115132 0.269977 0.208982 0.215461 0.039951 0.416667
12 0.108307 0.000000 0.000000 1.000000 0.000000 0.535699 0.000000 0.000000 0.000000 0.250000
In [20]:
result = pd.concat([merged.select_dtypes(np.object), df_num], axis=1)
result
Out[20]:
2012-12-05 0 1 2 3 4 5 6 7 8 9
0 2013-04-17 0.067448 0.319631 0.492537 0.043170 0.528783 1.000000 0.173987 1.000000 0.440280 0.375000
1 2013-07-29 0.064345 0.847014 0.537313 0.781385 0.199013 0.304476 0.140648 0.885189 0.687397 0.583333
2 2014-04-03 0.193237 0.103599 0.298507 0.000000 1.000000 0.780053 0.726352 0.425947 0.329077 0.000000
3 2014-08-12 1.000000 0.792334 1.000000 0.647557 0.215461 0.103558 0.491464 0.425947 0.081960 1.000000
4 2015-06-16 0.167391 0.191533 0.104478 0.034450 0.064145 0.527365 0.112363 0.272866 0.128913 0.250000
5 2015-09-13 0.187981 0.187390 0.179104 0.241884 0.231086 0.272194 0.037593 0.502488 0.064662 0.250000
6 2016-03-05 0.040236 0.520198 0.253731 0.018995 0.064145 0.584197 1.000000 0.693838 0.200577 0.250000
7 2016-09-18 0.328467 0.967369 0.179104 0.005698 0.450658 0.000000 0.057760 0.043245 0.074547 0.416667
8 2017-03-15 0.368364 1.000000 0.194030 0.064367 0.094572 0.764094 0.318602 0.081515 1.000000 0.583333
9 2018-02-11 0.411526 0.337752 0.089552 0.922121 0.481086 0.783777 0.206712 0.119786 0.026359 0.050000
10 2018-08-09 0.000000 0.799093 0.626866 0.012347 0.138980 0.603792 0.145983 0.672024 0.138797 0.916667
11 2018-10-27 0.728560 0.862290 0.223881 0.278795 0.115132 0.269977 0.208982 0.215461 0.039951 0.416667
12 2019-02-15 0.108307 0.000000 0.000000 1.000000 0.000000 0.535699 0.000000 0.000000 0.000000 0.250000
In [21]:
result.to_csv("metztitlan2_merged.csv",index=False, header=False)
In [23]:
os.chdir("fisher-nodo/")
In [24]:
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)