Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/StringConcatenator #52

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions examples/strings/StringConcatenator.ipynb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# StringConcatenator\n",
"This notebook shows the functionality of the `StringConcatenator` class. This transformer joins values from different columns into a new string in a new column."
"This notebook shows the functionality of the `StringConcatenator` class. Thjis Transformer combines data from specified columns, of mixed datatypes, into a new column containing one string."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

]
},
{
Expand Down Expand Up @@ -61,7 +62,7 @@
"metadata": {},
"outputs": [],
"source": [
"character_df = pd.DataFrame(([':', ')'], [':', '(']), columns=['c1', 'c2'])"
"character_df = pd.DataFrame(([':', ')', 5], [':', '(', 3]), columns=['c1', 'c2', 'c3'])"
]
},
{
Expand Down Expand Up @@ -92,27 +93,30 @@
" <th></th>\n",
" <th>c1</th>\n",
" <th>c2</th>\n",
" <th>c3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>:</td>\n",
" <td>)</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>:</td>\n",
" <td>(</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" c1 c2\n",
"0 : )\n",
"1 : ("
" c1 c2 c3\n",
"0 : ) 5\n",
"1 : ( 3"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -154,7 +158,7 @@
"metadata": {},
"outputs": [],
"source": [
"to_merge = ['c1', 'c2']\n",
"to_merge = ['c1', 'c2', 'c3']\n",
"\n",
"join_columns = StringConcatenator(to_merge, \"merged\", \"-\")"
]
Expand Down Expand Up @@ -211,6 +215,7 @@
" <th></th>\n",
" <th>c1</th>\n",
" <th>c2</th>\n",
" <th>c3</th>\n",
" <th>merged</th>\n",
" </tr>\n",
" </thead>\n",
Expand All @@ -219,22 +224,24 @@
" <th>0</th>\n",
" <td>:</td>\n",
" <td>)</td>\n",
" <td>:-)</td>\n",
" <td>5</td>\n",
" <td>:-)-5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>:</td>\n",
" <td>(</td>\n",
" <td>:-(</td>\n",
" <td>3</td>\n",
" <td>:-(-3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" c1 c2 merged\n",
"0 : ) :-)\n",
"1 : ( :-("
" c1 c2 c3 merged\n",
"0 : ) 5 :-)-5\n",
"1 : ( 3 :-(-3"
]
},
"execution_count": 8,
Expand Down
4 changes: 2 additions & 2 deletions tubular/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def transform(self, X):

class StringConcatenator(BaseTransformer):
"""
Transformer to concatenate values from a few columns into 1 string.
Transformer to combine data from specified columns, of mixed datatypes, into a new column containing one string.

Parameters
----------
Expand Down Expand Up @@ -167,7 +167,7 @@ def __init__(self, columns, new_column="new_column", separator=" "):

def transform(self, X):
"""
Concatenates values into one string.
Combine data from specified columns, of mixed datatypes, into a new column containing one string.

Parameters
----------
Expand Down