{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " name age state point\n", "0 Alice 24 NY 64\n", "1 Bob 42 CA 92\n", "2 Charlie 18 CA 70\n", "3 Dave 68 TX 70\n", "4 Ellen 24 CA 88\n", "5 Frank 30 NY 57\n" ] } ], "source": [ "df = pd.read_csv('data/src/sample_pandas_normal.csv')\n", "print(df)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " name age state point\n", "2 Charlie 18 CA 70\n", "5 Frank 30 NY 57\n", "4 Ellen 24 CA 88\n", "1 Bob 42 CA 92\n", "0 Alice 24 NY 64\n", "3 Dave 68 TX 70\n" ] } ], "source": [ "df_s = df.sample(frac=1)\n", "print(df_s)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " name age state point\n", "5 Frank 30 NY 57\n", "2 Charlie 18 CA 70\n", "1 Bob 42 CA 92\n", "3 Dave 68 TX 70\n", "0 Alice 24 NY 64\n", "4 Ellen 24 CA 88\n" ] } ], "source": [ "df_s = df.sample(frac=1, random_state=0)\n", "print(df_s)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " name age state point\n", "0 Ellen 24 CA 88\n", "1 Charlie 18 CA 70\n", "2 Alice 24 NY 64\n", "3 Dave 68 TX 70\n", "4 Frank 30 NY 57\n", "5 Bob 42 CA 92\n" ] } ], "source": [ "df_s = df.sample(frac=1).reset_index(drop=True)\n", "print(df_s)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " name age state point\n", "0 Dave 68 TX 70\n", "1 Bob 42 CA 92\n", "2 Charlie 18 CA 70\n", "3 Alice 24 NY 64\n", "4 Ellen 24 CA 88\n", "5 Frank 30 NY 57\n" ] } ], "source": [ "df = df.sample(frac=1).reset_index(drop=True)\n", "print(df)" ] } ], "metadata": { "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.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }