Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
| Següent revisió | Revisió prèvia | ||
| development:python:pandas [10/10/2024 04:53] – creat mate | development:python:pandas [10/10/2024 07:14] (actual) – [Python Pandas] mate | ||
|---|---|---|---|
| Línia 5: | Línia 5: | ||
| </ | </ | ||
| - | == pandas + bokeh | + | * Estilos: [[https:// |
| + | * datos: [[https:// | ||
| + | |||
| + | = varios | ||
| + | == importar en dataframe | ||
| + | * '' | ||
| + | * '' | ||
| + | == columnas | ||
| + | <code python> | ||
| + | * '' | ||
| + | * acceder columnas:< | ||
| + | df.columns[inicial: | ||
| + | * pueden ser indices numéricos o nombres | ||
| + | * acceder indices:< | ||
| + | * asignar nombres de columna:< | ||
| + | * asignar indice:< | ||
| + | * '' | ||
| + | * '' | ||
| + | == manipulación datos | ||
| + | Para acceder a datos en el dataframe es como un sistema de coordenadas | ||
| + | === label based indexing | ||
| + | * loc[start_value_row; | ||
| + | <code python> | ||
| + | df.loc[" | ||
| + | list(df.loc[:," | ||
| + | </ | ||
| + | * se puede indicar solo un valor en los rangos | ||
| + | |||
| + | === position based indexing | ||
| + | iloc[start_value_row; | ||
| + | <code python> | ||
| + | df.iloc[1: | ||
| + | </ | ||
| + | * '' | ||
| + | |||
| + | == borrar columnas | ||
| + | * '' | ||
| + | * los cambios no son '' | ||
| + | <code python> | ||
| + | df.drop(" | ||
| + | df.drop(df.index[0: | ||
| + | df.drop(df.columns[0: | ||
| + | </ | ||
| + | |||
| + | == añadir columnas | ||
| + | <code python> | ||
| + | df.shape[0] # número de filas | ||
| + | df.shape[1] # número de columnas | ||
| + | </ | ||
| + | <code python> | ||
| + | <code python> | ||
| + | |||
| + | == Transposición, | ||
| + | <code python> | ||
| + | df_T[" | ||
| + | df = df_T.T # función de transposición | ||
| + | </ | ||
| + | == pandas + bokeh ejemplos | ||
| <code python> | <code python> | ||
| # segundo bokeh plot con pandas | # segundo bokeh plot con pandas | ||
| Línia 24: | Línia 81: | ||
| show(f) | show(f) | ||
| </ | </ | ||
| + | <code python> | ||
| + | import pandas | ||
| + | |||
| + | from bokeh.plotting import figure, output_file, | ||
| + | |||
| + | df=pandas.read_excel(" | ||
| + | df[" | ||
| + | df[" | ||
| + | |||
| + | p=figure(width=500, | ||
| + | |||
| + | p.title.text=" | ||
| + | p.title.text_color=" | ||
| + | p.title.text_font=" | ||
| + | p.title.text_font_style=" | ||
| + | p.xaxis.minor_tick_line_color=None | ||
| + | p.yaxis.minor_tick_line_color=None | ||
| + | p.xaxis.axis_label=" | ||
| + | p.yaxis.axis_label=" | ||
| + | |||
| + | # old versions: | ||
| + | # p.circle(df[" | ||
| + | |||
| + | p.scatter(x=df[" | ||
| + | output_file(" | ||
| + | show(p) | ||
| + | </ | ||
| + | * desde Jupyter Notebook problema leyendo fichero desde URL | ||
| + | |||