-
-
Save verasativa/c7be95ab77652c7806ba3aedd749ee98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Como viene una columna de vecha y 4 de hora, hay que parsearlas convinadas | |
rdf = pd.read_excel('data.xlsx', header = None, parse_dates = [[0,1], [0,3], [0,5], [0,7]]) | |
# Renombramos las columnas y concatenamos en una sola tabla de timestamp y altura | |
col_map = { | |
'0_1': 'datetime', | |
'0_3': 'datetime', | |
'0_5': 'datetime', | |
'0_7': 'datetime', | |
2: 'rheight', | |
4: 'rheight', | |
6: 'rheight', | |
8: 'rheight', | |
} | |
frames = [rdf[['0_1', 2]].rename(columns=col_map), | |
rdf[['0_3', 4]].rename(columns=col_map), | |
rdf[['0_5', 6]].rename(columns=col_map), | |
rdf[['0_7', 8]].rename(columns=col_map)] | |
edf = pd.concat(frames).dropna() | |
# Eliminamos los 2 ultimos caracteres del valor de altura y lo convertimos de str a float | |
edf['height'] = edf.rheight.str[:-2].apply(float) | |
# ordenamos y eliminamos la altura cruda (string) | |
df = edf.drop(columns=['rheight']).sort_values(by='datetime').set_index('datetime') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment