Spaces:
Sleeping
Sleeping
eaglelandsonce
commited on
Commit
•
9346fae
1
Parent(s):
e93f572
Update pages/2_PandasIntro.py
Browse files- pages/2_PandasIntro.py +5 -5
pages/2_PandasIntro.py
CHANGED
@@ -97,9 +97,9 @@ def example15():
|
|
97 |
return explanation, code, pd.concat([df1, df2])
|
98 |
|
99 |
def example16():
|
100 |
-
explanation = "Pivoting a DataFrame."
|
101 |
-
code = "df = pd.DataFrame({'A': ['foo', 'bar', '
|
102 |
-
df = pd.DataFrame({'A': ['foo', 'bar', '
|
103 |
return explanation, code, df.pivot(index='A', columns='B', values='C')
|
104 |
|
105 |
def example17():
|
@@ -110,7 +110,7 @@ def example17():
|
|
110 |
|
111 |
def example18():
|
112 |
explanation = "Applying a function to a DataFrame."
|
113 |
-
code = "
|
114 |
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
|
115 |
return explanation, code, df.apply(lambda x: x + 1)
|
116 |
|
@@ -143,7 +143,7 @@ examples = [
|
|
143 |
("Example 13: Group by and aggregate a DataFrame", example13),
|
144 |
("Example 14: Merge two DataFrames", example14),
|
145 |
("Example 15: Concatenate two DataFrames", example15),
|
146 |
-
("Example 16: Pivot a DataFrame", example16),
|
147 |
("Example 17: Melt a DataFrame", example17),
|
148 |
("Example 18: Apply a function to a DataFrame", example18),
|
149 |
("Example 19: Join two DataFrames", example19),
|
|
|
97 |
return explanation, code, pd.concat([df1, df2])
|
98 |
|
99 |
def example16():
|
100 |
+
explanation = "Pivoting a DataFrame (using unique index)."
|
101 |
+
code = "df = pd.DataFrame({'A': ['foo', 'bar', 'baz'], 'B': ['one', 'two', 'one'], 'C': [1, 2, 3]})\ndf.pivot(index='A', columns='B', values='C')"
|
102 |
+
df = pd.DataFrame({'A': ['foo', 'bar', 'baz'], 'B': ['one', 'two', 'one'], 'C': [1, 2, 3]})
|
103 |
return explanation, code, df.pivot(index='A', columns='B', values='C')
|
104 |
|
105 |
def example17():
|
|
|
110 |
|
111 |
def example18():
|
112 |
explanation = "Applying a function to a DataFrame."
|
113 |
+
code = "df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\ndf.apply(lambda x: x + 1)"
|
114 |
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
|
115 |
return explanation, code, df.apply(lambda x: x + 1)
|
116 |
|
|
|
143 |
("Example 13: Group by and aggregate a DataFrame", example13),
|
144 |
("Example 14: Merge two DataFrames", example14),
|
145 |
("Example 15: Concatenate two DataFrames", example15),
|
146 |
+
("Example 16: Pivot a DataFrame (using unique index)", example16),
|
147 |
("Example 17: Melt a DataFrame", example17),
|
148 |
("Example 18: Apply a function to a DataFrame", example18),
|
149 |
("Example 19: Join two DataFrames", example19),
|