| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + import numpy as np | ||
| 2 | + | ||
| 3 | + values = np.arange(16).reshape(4,4) * 10 | ||
| 4 | + | ||
| 5 | + print(values) | ||
| 6 | + | ||
| 7 | + view = values[:, 1:3] | ||
| 8 | + print(view) | ||
| 9 | + | ||
| 10 | + view *= 0 | ||
| 11 | + print(view) | ||
| 12 | + | ||
| 13 | + print(values) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + import numpy as np | ||
| 2 | + | ||
| 3 | + values = np.arange(16).reshape(4, 4) | ||
| 4 | + print(values) | ||
| 5 | + print() | ||
| 6 | + | ||
| 7 | + print(values[[0, 2, 2, 3],[0, 0, 2, 1]]) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + import numpy as np | ||
| 2 | + | ||
| 3 | + values = np.arange(16).reshape(4, 4) | ||
| 4 | + print(values) | ||
| 5 | + print() | ||
| 6 | + | ||
| 7 | + print(values % 2 == 0) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + import numpy as np | ||
| 2 | + | ||
| 3 | + values = np.arange(16).reshape(4, 4) | ||
| 4 | + print(values) | ||
| 5 | + print() | ||
| 6 | + | ||
| 7 | + print(values[values % 5 == 0]) | ||
| 8 | + | ||
| 9 | + rng = np.random.default_rng() | ||
| 10 | + | ||
| 11 | + numbers = rng.standard_normal(50) | ||
| 12 | + print(numbers.mean()) | ||
| 13 | + | ||
| 14 | + positives = numbers[numbers < 0] | ||
| 15 | + print(positives.mean()) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + | ||
| 3 | + df = pd.read_csv('exercises.csv', sep='\s*,\s*', index_col=0) | ||
| 4 | + | ||
| 5 | + print(df.columns) | ||
| 6 | + | ||
| 7 | + print(df.head()) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + | ||
| 3 | + df = pd.read_csv('exercises.csv', sep=',', index_col=0) | ||
| 4 | + | ||
| 5 | + df.columns = df.columns.str.strip() | ||
| 6 | + | ||
| 7 | + print(df.columns) | ||
| 8 | + print(df.head()) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + | ||
| 3 | + df = pd.read_csv('exercises.csv', sep=',', index_col=0) | ||
| 4 | + df.columns = df.columns.str.strip() | ||
| 5 | + | ||
| 6 | + df.at['Tue', 'Pushups'] = 40 | ||
| 7 | + | ||
| 8 | + print("Monday squats", df.iat[0, 2]) | ||
| 9 | + | ||
| 10 | + print(df) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + | ||
| 3 | + df = pd.read_csv('exercises.csv', sep=',', index_col=0) | ||
| 4 | + df.columns = df.columns.str.strip() | ||
| 5 | + | ||
| 6 | + print(df) | ||
| 7 | + | ||
| 8 | + print(df.loc["Mon":"Sun":2]) | ||
| 9 | + print(df.loc[["Fri", "Mon"], "Pushups":"Squats"]) | ||
| 10 | + print(df.loc[:, "Pushups":"Squats"]) | ||
| 11 | + | ||
| 12 | + print(df.iloc[:, 1:3]) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + | ||
| 3 | + data = { | ||
| 4 | + "Mon":[1, 2, 3], | ||
| 5 | + "Tue":[0.1, 0.2, 0.3], | ||
| 6 | + "Wed":[5, 6, 7], | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + df = pd.DataFrame(data) | ||
| 10 | + print(df) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + import pandas as pd | ||
| 2 | + import numpy as np | ||
| 3 | + | ||
| 4 | + data = { | ||
| 5 | + "Mon":[1, 2, 3], | ||
| 6 | + "Tue":[0.1, 0.2, 0.3], | ||
| 7 | + "Wed":[5, 6, 7], | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + df = pd.DataFrame(data, index=["Coffee", "Tea", "Water"]) | ||
| 11 | + print(df) | ||
| 12 | + print() | ||
| 13 | + | ||
| 14 | + df *= 3.0 | ||
| 15 | + print(df) | ||
| 16 | + | ||
| 17 | + print() | ||
| 18 | + df = np.sin(df) | ||
| 19 | + print(df) | ||
| 20 | + | ||
| 21 | + df.loc["Coffee":"Tea"] -= 100 | ||
| 22 | + print(df) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments