Monday, January 30, 2017

Efficiency


I have been reflecting on my dashboards performance...

You may have noticed that the Ecobici dashboard I presented on my previous couple of posts takes a while to refresh every time you filter the views. This exercise is using a considerable number of rows and there are some optimization tricks that I should have then taken into consideation.

To begin with, it would have helped to calculate some fields in the source file instead of making the calculations in Tableau:
  • The distance calculation is a clear example and I should have done it just as I did with the trip time.
  • In the end, it was not a good idea to merge the date and time values into a single column and rely on Tableau's functions to calculate YEAR, WEEKDAY, DAY, HOUR, etc. It is much more efficient to have distinct columns for the measures being used.

There are other factors to consider for responsive dashboards and I've found a couple of nice articles that may be helpful to go deeper in this topic:

For now, I only added the date and distance calculations on the source file and this had a significant impact on the performance:




Wednesday, January 25, 2017

Data Cleansing

I want to elaborate a little bit more on the process I followed to construct the Ecobici dashboard in my previous entry.

The original file included almost 690 thousand rows corresponding to the trips that public bike users made in December 2016. The raw archive was provided in the following format:

Genero_Usuario,Edad_Usuario,Bici,Ciclo_Estacion_Retiro,Fecha_Retiro,Hora_Retiro,Ciclo_Estacion_Arribo,Fecha_Arribo,Hora_Arribo
M,33,3340,24,01/12/2016,12:00:07 AM,123,01/12/2016,12:14:48 AM
M,36,7863,75,01/12/2016,12:00:28 AM,278,01/12/2016,12:09:24 AM
F,45,2964,365,01/12/2016,12:00:37 AM,369,01/12/2016,12:08:20 AM
...

It is a text file that can be opened with Excel. The guiding wizard will ask for a few parameters to determine what character is being used as a column separator (a comma in this case) and the data type for each column. I guess this file could be handled directly from Tableau, but I found it easier to make some arrangements first in Excel:

  • Merging columns

    The original file contains separate columns for the dates and times when each trip begins and also for when it ends (four columns in total). I decided to merge the information into a single column for the departures and another one for the arrivals (two columns). I simply concatenated the values in Excel, but it's important to take care of the data types that Excel assigns to each column or this concatenation will result in some bizarre values. While exporting the CSV file with the Excel wizard, make sure to choose the Text type for the dates and times columns, or you could also use the function TEXT(value,format)if you selected the default General type while pulling the data.

    I later learned that Tableau is a little picky on the time formatting and I also had to convert the values to the 24hrs convention instead of the am/pm used in the original file. In the end, this was the function I used:
    CONCATENATE(A1," ",TEXT(B1,"HH:MM:SS"))

  • Joins (vlookup)

    The original file includes the station IDs for the origin and destination of each trip. However, I also wanted to know the address of each point so that I could draw the points into a map.

    Ecobici offers a JSON service that in real time publishes the bike availability per station. This document can be easily converted to a CSV file containing the following information:

    id,district,lon,lat,bikes,slots,zip,address,addressNumber,nearbyStations,status,name,stationType
    1,CUA,-99.168051,19.433296,13,14,06500,001 - Río Balsas-Río Sena,S/N,"2,3,85",OPN,1 RIO BALSAS-RIO SENA,"BIKE,TPV"
    2,CUA,-99.171695,19.431386,2,8,06500,002 - Río Guadalquivir - Río Balsas,S/N,"1,5",OPN,2 RIO GUADALQUIVIR-RIO BALSAS,BIKE
    ...


    From this file I created a catalogue where I could find the latitud, longitud and name of each station using VLOOKUP(value,range,column).

  • Calculated fields

    There are at least a couple of measures that were not included in the original dataset, but that can be determined from the provided data. In this case, I was interested in knowing more about each trip:

    1. Time spent on each trip: This is a trivial substraction between two columns in Excel.
    2. Distance between the origin and destination: I used the haversine formula to calculate the distance between two points expressed as latitude and longitude. This is also an easy computation, but this time I made it in Tableau because I came to this idea once I had already imported the data to the tool. It is important to note that this is just an estimation because it considers a straight line between the origin and destination, and not the real route that could be very different and much longer. It also disregards the extra distance that result from biking up and down any elevation variances. 

    I have also been considering it would be interesting to observe the deficit and superavit of bikes each station may have at different times during the day. This is an important metric for service operators to relocate the bikes from where there are too many, to where there are shortages. I'll probably leave this exercise for the future.

Monday, January 16, 2017

Bike Share in Mexico City


Playing with open data for public bike usage in Mexico City!




For this observation, I downloaded some of the open data provided by Ecobici in Mexico City. I specifically used the December 2016 results which are available as a CSV archive that contains information of 688,657 trips. Although December may be atypical because of the holidays, some interesting observations result from the exploration of the data:
  • The busiest time of the week is Thursdays 8am.
  • The busiest origin stations are not necessarily the same as the busiest destination stations.
OriginTrips
REFORMA-HAVRE 8,319
REFORMA-RIO SENA 5,837
RIO BALSAS-RIO SENA 5,482
AV. CENTRAL-J. MENESES                  5,443
REFORMA-LIEJA 5,268
      
DestinationTrips
REFORMA-HAVRE 8,335
AV. JESÚS GARCIA-CARLOS J. MENESES 6,061
REFORMA-RIO SENA 5,882
RIO BALSAS-RIO SENA 5,605
AVENIDA MEXICO-SONORA 5,390
  • It is also interesting to observe that the daily origin heatmap varies for each station:
    • If the heatmap is skewed towards the morning, probably the location corresponds to a residential area where users are riding from home to work (or school, or wherever people begin their daily activities).
      For example, select station 266 AV. JESÚS GARCIA-CARLOS J. MENESES (don't forget to click the filtered station on the origin map).
    • If the heatmap is more active around 18hrs, this may signify that more offices are located around the zone and are using the station to leave from work.
      For example, filter by station 27 REFORMA-HAVRE.
  • The longest trip in December was of 10.36km (note that this is just a straight line approximation) and it took place from 244 EJERCITO NACIONAL-F.C. DE CUERNAVACA to 445 RIFF-AVENIDA RIO CHURUBUSCO. However, the average trip is just 1.639km and the average time of usage is 14.5mins, does this mean the average speed is only 6.78km/h?

Monday, November 14, 2016

Transportation Network Reflections

  1. Use the attached data to think about and answer the questions below.  Most importantly, we'd like to understand your interpretation of the data, thought process and ideas.
    a. In your view, which channels were most successful? Why?  How would you recommend optimizing this spend, and what other data would you need / use to do that?
    b. Assuming the data represents one purchase of ads, and the conversion from Signup (application) to Active Driver was very low…
    i. What would you alter for next time?
    ii. What strategies would you implement next for applicants that didn’t convert?
  2. You have 50+ stakeholders to manage - how do you come up with systems/processes that addresses each individual needs on the following:
    a. How do you deal with 50+ stakeholders, across 3 regions in the US + CA with over 100 cities. Each city has different stakeholders at level from Regional General Managers, City General Managers and City Marketing Managers
    b. Provide them with weekly reporting on core performance
    c. Provide them with support for their local marketing needs
    d. What Communication Flow and Cadence would you put in place?
  3. Related to Q1, what Team Structure would you put in place to support all these cities and regional managers. What are the key roles you would hire for?
  4. Related to Q1, what local marketing strategies would you develop. What areas of marketing should be HQ driven vs local driven at the city and region level. What areas can city teams and central marketing teams best collaborate on, to drive overall marketing growth and be as localized as possible?
  5. The company has overall rider and driver growth goals for the region (US) as well as for each city. It is important to stick to both driver and rider goals, to ensure city market balance and health is maintained. How would you best leverage central teams across online media, offline media, strategy, CRM, SEO, analytics, etc to deliver results for every city?
  6. We’ve been live in a city for 6 months, and have a steady flow of organic new riders coming in - however, we want more. Outline three strategies you would use to attract new riders, and how you would measure channel efficacy.
  7. We’re live in a city in the US, that has been growing demand rapidly. That has been putting a lot of pressure on supply (drivers). Outline three strategies you would use to attract new driver partners, and how you would measure channel efficacy.

Tuesday, April 1, 2003

(Re-Publish) 2002-2003 part 2

This entry was edited from an old post in www.geocities.com/jaltacol...

Comencé a ambientarme de nuevo y a llenar aplicaciones de trabajo por internet. Primero llenaría aplicaciones para empresas grandes y reconocidas y luego para los sitios de búsqueda de empleo. El proceso es lento y tedioso y me rindió muy pocos frutos, pues la mayoría de las aplicaciones no merecieron siquiera acuse de recibo. Algunas aplicaciones fueron rechazadas pues me dijeron sólo se contrataba a gente con "work permit" y que ellos no podían ayudar en el trámite del mismo. Por mi cuenta no podía tramitar el dichoso permiso de trabajo, pues requería de un empleador o patrocinador que lo tramitara por mí. Así que se trataba de un círculo vicioso en el que para conseguir trabajo se necesita de "work permit", pero para conseguir "work permit" se necesita tener trabajo.

Llegó Navidad y Año Nuevo y el clima se ponía ya más frío. De hecho este año a diferencia del anterior, si nevó varias veces y se alcanzaron a poner las calles blancas por mucho más tiempo. Para Navidad pasé Navidad en el único antro de Northallerton y varias millas a la redonda, en una noche  punchis-punchis. Una experiencia un tanto rara y hasta el día siguiente, 25 de diciembre, celebramos Navidad (los ingleses no saben que la onda es cenar en familia el 24 y a las 12 de la noche poner al Niño en el Nacimiento).

Año Nuevo también fue un tanto diferente a lo que tenía acostumbrado. En esta ocasión el chiste consistió en ir a un pub y tomar y tomar hasta que poco antes de las doce de la noche se dió la cuenta regresiva, los abrazos y se cantó (a tonada de la rola del Camp los Ícaros):


“Should all acquaintance be forgot
and never brought to mind
Should all acquaintance be forgot
for the sake of auld lang syne”

 
Terminadas las celebraciones navideñas, seguí aplicando y llenando formas por internet. Mandando correos, electrónicos e impresos. Luego, en enero, fue mi graduación y me tuve que disfrazar de acuerdo a tradiciones y normas que datan de principios de la Edad Media. Para la toga se sigue la usanza Oxford y para el capuchón el estilo Cambridge (el capuchón no es el birrete, es efectivamente un capuchón te ponen encima de la toga). Los colores del capuchón van de acuerdo al grado y facultad del graduado. Así que por ser un graduado de MSc Data Coms de la facultad de Electrónica, pues obviamente me tocó un capuchón verde con morado.

Pasó enero y vino febrero. Conocí Oxford cuando al ser plantado en una entrevista decidí permanecer en el lugar por una noche y aceptar una entrevista al día siguiente. Me pareció el lugar más bonito de lo que vi en Inglaterra. Edificios realmente bellos por todos lados, pero no fui a Cambridge que se supone también es muy bonito. Me quedé en casa de Liv que a penas había conocido en Navidad y conocí a Justin, el malabarista, que muy amablemente me llevó al Turf Tavern (uno de los pubs más viejos de Inglaterra). Más tarde fuimos a un pub de música viva para escuchar Jazz y ver perder al Sheffield United contra Liverpool en la semifinal de la Worthington Cup. Al día siguiente vi a López Portillo y regresé en la tarde a Sheffield.


Luego, un sábado fui al acuario de Hull y a conocer la ciudad, que aunque tiene fama de ser ciudad gacha, violenta y peligrosa, no me pareció así. Será que estoy curado de espanto al ser chilango y los barrios bravos ingleses no me parecieron tanto. La ciudad me pareció como cualquier otra ciudad inglesa, el acuario me gustó mucho y lo que se ve en la foto de la derecha, la versión inglesa del Golden Gate, me pareció valió la pena de visitar (the picture on the right is actually two pictures pasted together; both pictures were taken by Jess).

 

Otro fin de semana, fui invitado a ir a Londres para visitar a Stu y ver la exposición de Aztecs en el London Academy of Arts. Eran mis últimos días en Inglaterra y aunque no tenía aún mi boleto de regreso a México, ya sabía que muy pronto debería partir pues la situación laboral se mantenía sin cambios (seguía desempleado) y se acercaba el plazo que había marcado para mi regreso (la boda de Fernando).

Pero antes de que me ponga sentimental por haber dejado a mis amigos y haberme tenido que regresar mejor le paro a la escritura de esta página. Finalmente creo que aunque no encontrara trabajo y se me acabara el veinte de esta etapa, esos pocos meses se pueden resumir en una experiencia muy agradable.

Para terminar más fotos. Ahora de cuando fui a Irlanda en febrero con mi amigo Top.


Monday, March 31, 2003

(Re-Publish) 2002-2003 part 1

This entry was edited from an old post in www.geocities.com/jaltacol...

Terminada mi tesis compré mi boleto de avión Manchester-Frankfurt-México y tomé la decisión de comprar un billete redondo.

Llegado el día, después de un buen rato de travesía, por fin llegué a México un poco antes del día de la Independencia. Hacía un año exactamente que celebraba en París las fiestas patrias, pero en esta ocasión la pasé en casa (o tal vez mejor dicho, en casa de mis padres) y sin mayores festejos que sintonizar la televisión unos 15 minutos para ver el Grito e irme a dormir.

Luego, pasaron casi tres semanas antes de que llegaran las visitas europeas y junto con Luis paseamos por 20 días. Vistamos San Miguel de Allende, Tequisquiapan, Teotihuacan, Malinalco, Tula, Puebla, Veracruz, Catemaco, Palenque, Agua Azul, San Cristobal de las Casas, Tuxtla Gutiérrez, Oaxaca y el DF (sin contar el chorro de pueblos por los que pasamos y nos detuvimos a comer, estirar las piernas, tomar la foto o usar los baños).




Terminó el tour por México, pero antes de seguir con la historia y pasar a lo que ocurrió después, platicaré lo que pasó el primer fin de semana que estuvieron aquí mis visitas europeas. Resulta que Chucho y Vic al saber que estaba de regreso y que había traído a Jess y Katrin de paseo, me hablaron para organizar una salida de sábado por la noche. Coordinamos vernos en la cantina "La Hija de Moctezuma" y para cuando llegué ya estaban muy en ambiente. Así que bailamos y platicamos un rato en el lugar para después irnos a la salsa en el "Meneo", pero no llegamos muy lejos pues a penas a medio camino, cambiaron los planes.

Venía manejando el Jetta verde, seguido por Vic en su Chevy y Chucho al final en su Escort. Casi al llegar al crucero de Benjamín Franklin y Revolución, frené al ver la luz ambar, se escuchó el rechinón de llantas del Chevy y Chucho desde atrás observa una mata de pelo negro agitándose violentamente hacia adelante. Bajamos a estimar el daño que aunque para el Jetta no ocasionó más que una leve raspadura, para el Chevy si repercutió en la parrilla, el cofre, un faro y el radiador dañados. Ninguno de los tripulantes resultamos lastimados más allá de un tirón de cuello de la inglesa, pero obviamente los ánimos de fiesta se agüitaron (para algunos) y así los del Jetta mejor regresamos a dormir. Sin embargo, Vic y Chucho no perdieron las ganas y siguieron la fiesta. Hasta ahí ya resultaba el hecho una anécdota entretenida, pero lo que nunca me hubiera imaginado es que aquella noche era el principio de lo que por poco termina en tragedia. Resulta que Chucho se pensaba casar.

Así es, la noche del percance automovilístico arriba relatada, Chucho y Vic se fueron de fiesta y fue entonces cuando Sandra, la novia de Vic le presentó al pobre Chuchito a la que tres días después sería su prometida. Todo fue tan rápido que nos fuimos de viaje por la República y a penas regresando tres semanas después, ya estaba la boda planeada para diciembre. De lo que a la mera hora pasó, me enteré mediante el siguiente mensaje.

En fin. Después del viaje por México y enterado de que mi amigo estaba comprometido, comenzaron los arreglos para el regreso a Inglaterra. Como no había mucho que arreglar me la pasé un par de semanas de flojo, pero pasado mi cumpleaños y mi operación de las muelas del juicio, estaba listo para regresar al Viejo Mundo en busca de un trabajo. Así empezaba mi segunda estancia en Sheffield.

Monday, March 24, 2003

(Re-Publish) Sheffield 2002-2003


This entry was edited from an old post in www.geocities.com/jaltacol...

Para mostrar lo que ocurrió en mis últimos meses de la maestría y para ocupar un poco del tiempo libre que tuve al regresar a México, hice el siguiente video.