Skip to content

Commit 73be7e6

Browse files
committed
Created using Colaboratory
1 parent 67639a0 commit 73be7e6

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

pandas/apply.ipynb

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"name": "apply.ipynb",
7+
"provenance": [],
8+
"include_colab_link": true
9+
},
10+
"kernelspec": {
11+
"name": "python3",
12+
"display_name": "Python 3"
13+
}
14+
},
15+
"cells": [
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {
19+
"id": "view-in-github",
20+
"colab_type": "text"
21+
},
22+
"source": [
23+
"<a href=\"https://colab.research.google.com/github/tinhb92/relax_ml/blob/master/pandas/apply.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"metadata": {
29+
"id": "AYIHr7yMISYZ",
30+
"colab_type": "code",
31+
"colab": {}
32+
},
33+
"source": [
34+
"import numpy as np\n",
35+
"import pandas as pd"
36+
],
37+
"execution_count": 0,
38+
"outputs": []
39+
},
40+
{
41+
"cell_type": "code",
42+
"metadata": {
43+
"id": "bnE39B78HxDL",
44+
"colab_type": "code",
45+
"colab": {}
46+
},
47+
"source": [
48+
"df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B'])"
49+
],
50+
"execution_count": 0,
51+
"outputs": []
52+
},
53+
{
54+
"cell_type": "code",
55+
"metadata": {
56+
"id": "96-jbKvaIM5l",
57+
"colab_type": "code",
58+
"colab": {
59+
"base_uri": "https://localhost:8080/",
60+
"height": 136
61+
},
62+
"outputId": "00f3c564-368a-4b0a-ccc5-2a8dadd938a6"
63+
},
64+
"source": [
65+
"df.apply(np.sqrt)"
66+
],
67+
"execution_count": 7,
68+
"outputs": [
69+
{
70+
"output_type": "execute_result",
71+
"data": {
72+
"text/html": [
73+
"<div>\n",
74+
"<style scoped>\n",
75+
" .dataframe tbody tr th:only-of-type {\n",
76+
" vertical-align: middle;\n",
77+
" }\n",
78+
"\n",
79+
" .dataframe tbody tr th {\n",
80+
" vertical-align: top;\n",
81+
" }\n",
82+
"\n",
83+
" .dataframe thead th {\n",
84+
" text-align: right;\n",
85+
" }\n",
86+
"</style>\n",
87+
"<table border=\"1\" class=\"dataframe\">\n",
88+
" <thead>\n",
89+
" <tr style=\"text-align: right;\">\n",
90+
" <th></th>\n",
91+
" <th>A</th>\n",
92+
" <th>B</th>\n",
93+
" </tr>\n",
94+
" </thead>\n",
95+
" <tbody>\n",
96+
" <tr>\n",
97+
" <th>0</th>\n",
98+
" <td>2.0</td>\n",
99+
" <td>3.0</td>\n",
100+
" </tr>\n",
101+
" <tr>\n",
102+
" <th>1</th>\n",
103+
" <td>2.0</td>\n",
104+
" <td>3.0</td>\n",
105+
" </tr>\n",
106+
" <tr>\n",
107+
" <th>2</th>\n",
108+
" <td>2.0</td>\n",
109+
" <td>3.0</td>\n",
110+
" </tr>\n",
111+
" </tbody>\n",
112+
"</table>\n",
113+
"</div>"
114+
],
115+
"text/plain": [
116+
" A B\n",
117+
"0 2.0 3.0\n",
118+
"1 2.0 3.0\n",
119+
"2 2.0 3.0"
120+
]
121+
},
122+
"metadata": {
123+
"tags": []
124+
},
125+
"execution_count": 7
126+
}
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"metadata": {
132+
"id": "puajjOwmIUM5",
133+
"colab_type": "code",
134+
"colab": {
135+
"base_uri": "https://localhost:8080/",
136+
"height": 84
137+
},
138+
"outputId": "70abfc24-77d2-42a2-8442-d47208d84377"
139+
},
140+
"source": [
141+
"df.apply(lambda x: [1, 2], axis=1)"
142+
],
143+
"execution_count": 8,
144+
"outputs": [
145+
{
146+
"output_type": "execute_result",
147+
"data": {
148+
"text/plain": [
149+
"0 [1, 2]\n",
150+
"1 [1, 2]\n",
151+
"2 [1, 2]\n",
152+
"dtype: object"
153+
]
154+
},
155+
"metadata": {
156+
"tags": []
157+
},
158+
"execution_count": 8
159+
}
160+
]
161+
},
162+
{
163+
"cell_type": "code",
164+
"metadata": {
165+
"id": "qfJ9kOeZIbSM",
166+
"colab_type": "code",
167+
"colab": {}
168+
},
169+
"source": [
170+
""
171+
],
172+
"execution_count": 0,
173+
"outputs": []
174+
}
175+
]
176+
}

0 commit comments

Comments
 (0)