From 1ea4303775cad35e7ca5fab66009268f3b269dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 29 Jul 2022 16:13:41 +0200 Subject: [PATCH] Pandas --- README.md | 11 ++++++----- index.html | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 96ea90b..b383512 100644 --- a/README.md +++ b/README.md @@ -3105,9 +3105,10 @@ if __name__ == '__main__': Pandas ------ ```python -# $ pip3 install pandas +# $ pip3 install pandas matplotlib import pandas as pd from pandas import Series, DataFrame +import matplotlib.pyplot as plt ``` ### Series @@ -3151,7 +3152,7 @@ Name: a, dtype: int64 ```python .plot.line/area/bar/pie/hist() # Generates a Matplotlib plot. -matplotlib.pyplot.show() # Displays the plot. Also savefig(). +plt.show() # Displays the plot. Also plt.savefig(). ``` #### Series — Aggregate, Transform, Map: @@ -3310,12 +3311,12 @@ b 3 4 #### DataFrame — Plot, Encode, Decode: ```python -.plot.line/bar/hist/scatter() # Also: `x=column_key, y=column_key/s`. -import matplotlib.pyplot as plt; plt.show() # Displays the plot. +.plot.line/bar/hist/scatter/box() # Also: `x=column_key, y=column_key/s`. +plt.show() # Displays the plot. Also plt.savefig(). ``` ```python - = pd.read_json/html('') # Run `$ pip3 install lxml` to read html. + = pd.read_json/html('') # Run `$ pip3 install beautifulsoup4 lxml`. = pd.read_csv/pickle/excel('') # Use `sheet_name=None` to get all Excel sheets. = pd.read_sql('', ) # Accepts SQLite3 or SQLAlchemy connection. = pd.read_clipboard() # Reads a copied table from the clipboard. diff --git a/index.html b/index.html index 5d712e6..e7bcfe4 100644 --- a/index.html +++ b/index.html @@ -2538,9 +2538,10 @@ W, H, MAX_S = 50, 50< main() -

#Pandas

# $ pip3 install pandas
+

#Pandas

# $ pip3 install pandas matplotlib
 import pandas as pd
 from pandas import Series, DataFrame
+import matplotlib.pyplot as plt
 

Series

Ordered dictionary with a name.

>>> Series([1, 2], index=['x', 'y'], name='a')
@@ -2570,7 +2571,7 @@ Name: a, dtype: int64
 <Sr>.update(<Sr>)                              # Updates items that are already present.
 
<Sr>.plot.line/area/bar/pie/hist()             # Generates a Matplotlib plot.
-matplotlib.pyplot.show()                       # Displays the plot. Also savefig(<path>).
+plt.show()                                     # Displays the plot. Also plt.savefig(<path>).
 

Series — Aggregate, Transform, Map:

<el> = <Sr>.sum/max/mean/idxmax/all()          # Or: <Sr>.agg(lambda <Sr>: <el>)
 <Sr> = <Sr>.rank/diff/cumsum/ffill/interpl()   # Or: <Sr>.agg/transform(lambda <Sr>: <Sr>)
@@ -2701,11 +2702,11 @@ b  3  4
 
  • Use '<DF>[col_key_1, col_key_2][row_key]' to get the fifth result's values.
-

DataFrame — Plot, Encode, Decode:

<DF>.plot.line/bar/hist/scatter()              # Also: `x=column_key, y=column_key/s`.
-import matplotlib.pyplot as plt; plt.show()    # Displays the plot.
+

DataFrame — Plot, Encode, Decode:

<DF>.plot.line/bar/hist/scatter/box()          # Also: `x=column_key, y=column_key/s`.
+plt.show()                                     # Displays the plot. Also plt.savefig(<path>).
 
-
<DF> = pd.read_json/html('<str/path/url>')     # Run `$ pip3 install lxml` to read html.
+
<DF> = pd.read_json/html('<str/path/url>')     # Run `$ pip3 install beautifulsoup4 lxml`.
 <DF> = pd.read_csv/pickle/excel('<path/url>')  # Use `sheet_name=None` to get all Excel sheets.
 <DF> = pd.read_sql('<table/query>', <conn.>)   # Accepts SQLite3 or SQLAlchemy connection.
 <DF> = pd.read_clipboard()                     # Reads a copied table from the clipboard.