Documentos de Académico
Documentos de Profesional
Documentos de Cultura
De Datos
Sesión 3
Julio Morales León
Pandas
La función “Open” me permite leer un archivo
data3 = open(mainpath + "/" + "customer-churn-model/Customer Churn Model.txt",'r')
Output:
age 41.00000
ed 1.00000
employ 15.00000
address 14.00000
income 120.00000
debtinc 2.90000
creddebt 2.65872
othdebt 0.82128
default 0.00000
Name: 3, dtype: float64
Pandas
with open(infile, "r") as infile1:
with open(outfile, "w") as outfile1:
#Luego se lee linea por línea con el commando for:
for line in infile1:
fields = line.strip().split(",")
outfile1.write("\t".join(fields))
outfile1.write("\n")
Pandas