Last active
April 1, 2017 06:15
-
-
Save ksomemo/20e41f8cd4dad077a2b33c1d914f952d to your computer and use it in GitHub Desktop.
pandas.DataFrame.columnsにsuffixをつける ref: http://qiita.com/ksomemo/items/4d3346a7edc05f3bf9d2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": { | |
| "ExecuteTime": { | |
| "end_time": "2016-07-18T20:44:03.964002", | |
| "start_time": "2016-07-18T20:44:01.895809" | |
| }, | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>prefix_sepal_length_mean</th>\n", | |
| " <th>prefix_sepal_width_mean</th>\n", | |
| " <th>prefix_petal_length_mean</th>\n", | |
| " <th>prefix_petal_width_mean</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>prefix_species</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>setosa</th>\n", | |
| " <td>5.006</td>\n", | |
| " <td>3.428</td>\n", | |
| " <td>1.462</td>\n", | |
| " <td>0.246</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>versicolor</th>\n", | |
| " <td>5.936</td>\n", | |
| " <td>2.770</td>\n", | |
| " <td>4.260</td>\n", | |
| " <td>1.326</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>virginica</th>\n", | |
| " <td>6.588</td>\n", | |
| " <td>2.974</td>\n", | |
| " <td>5.552</td>\n", | |
| " <td>2.026</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " prefix_sepal_length_mean prefix_sepal_width_mean \\\n", | |
| "prefix_species \n", | |
| "setosa 5.006 3.428 \n", | |
| "versicolor 5.936 2.770 \n", | |
| "virginica 6.588 2.974 \n", | |
| "\n", | |
| " prefix_petal_length_mean prefix_petal_width_mean \n", | |
| "prefix_species \n", | |
| "setosa 1.462 0.246 \n", | |
| "versicolor 4.260 1.326 \n", | |
| "virginica 5.552 2.026 " | |
| ] | |
| }, | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "import pandas as pd\n", | |
| "import seaborn as sns\n", | |
| "sns.load_dataset(\"iris\").add_prefix(\"prefix_\").groupby(\"prefix_species\").mean().add_suffix(\"_mean\")" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "hide_input": false, | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.5.1" | |
| }, | |
| "toc": { | |
| "toc_cell": false, | |
| "toc_number_sections": true, | |
| "toc_threshold": 6, | |
| "toc_window_display": false | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import seaborn as sns | |
| sns.load_dataset("iris").add_prefix("prefix_").groupby("prefix_species").mean().add_suffix("_mean") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
動機
用途
参考