Skip to content

Instantly share code, notes, and snippets.

@decisionstats
Created March 9, 2017 15:02
Show Gist options
  • Save decisionstats/d2cada339547d3ece8dfa6a3dff86bde to your computer and use it in GitHub Desktop.
Save decisionstats/d2cada339547d3ece8dfa6a3dff86bde to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"iris=pd.read_csv(\"http://vincentarelbundock.github.io/Rdatasets/csv/datasets/iris.csv\",header=None)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>NaN</td>\n",
" <td>Sepal.Length</td>\n",
" <td>Sepal.Width</td>\n",
" <td>Petal.Length</td>\n",
" <td>Petal.Width</td>\n",
" <td>Species</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1.0</td>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2.0</td>\n",
" <td>4.9</td>\n",
" <td>3</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3.0</td>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4.0</td>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5\n",
"0 NaN Sepal.Length Sepal.Width Petal.Length Petal.Width Species\n",
"1 1.0 5.1 3.5 1.4 0.2 setosa\n",
"2 2.0 4.9 3 1.4 0.2 setosa\n",
"3 3.0 4.7 3.2 1.3 0.2 setosa\n",
"4 4.0 4.6 3.1 1.5 0.2 setosa"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris.head()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"iris2=iris.iloc[1:,1:]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"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>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.9</td>\n",
" <td>3</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 1 2 3 4 5\n",
"1 5.1 3.5 1.4 0.2 setosa\n",
"2 4.9 3 1.4 0.2 setosa\n",
"3 4.7 3.2 1.3 0.2 setosa\n",
"4 4.6 3.1 1.5 0.2 setosa\n",
"5 5 3.6 1.4 0.2 setosa"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris2.head()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import os as os"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'C:\\\\Users\\\\Dell\\\\Documents'"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.getcwd()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"iris2.to_csv(\"iris2.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 150 entries, 0 to 149\n",
"Data columns (total 6 columns):\n",
"Unnamed: 0 150 non-null int64\n",
"Sepal.Length 150 non-null float64\n",
"Sepal.Width 150 non-null float64\n",
"Petal.Length 150 non-null float64\n",
"Petal.Width 150 non-null float64\n",
"Species 150 non-null object\n",
"dtypes: float64(4), int64(1), object(1)\n",
"memory usage: 7.1+ KB\n"
]
}
],
"source": [
"iris.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"CREATE TABLE iris (\n",
"Sepal_Length real,\n",
"Sepal_Width real,\n",
"Petal_Length real,\n",
"Petal_Width real,\n",
"Species varchar(20) \n",
");\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'C:\\\\Users\\\\Dell\\\\Documents'"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.getcwd()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"os.chdir('C:\\\\Users\\\\Dell\\\\Desktop')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['.Rhistory',\n",
" '16508797_10155115909410362_414170078812994931_n.jpg',\n",
" '27032014_Duplicate_Statement.pdf',\n",
" '30072015_form_du-degree.pdf',\n",
" 'ACK.html',\n",
" 'ACK_files',\n",
" 'adult.data.txt',\n",
" 'AJAY.xps',\n",
" 'Basics of SQL & RDBMS _ Must Skills For Data Science Professionals.html',\n",
" 'Basics of SQL & RDBMS _ Must Skills For Data Science Professionals_files',\n",
" 'BigDiamonds (2).csv',\n",
" 'BigDiamonds.csv',\n",
" 'BigDiamonds.csv (2).zip',\n",
" 'BigDiamonds2.csv',\n",
" 'BLOOD REPORT.pdf',\n",
" 'CAM- Ajay Ohri.pdf',\n",
" 'cam.xps',\n",
" 'cam2.pdf',\n",
" 'cdo.jpeg',\n",
" 'clustersas.html',\n",
" 'dap class 4.R',\n",
" 'dap_class_4.html',\n",
" 'desktop.ini',\n",
" 'Dropbox.lnk',\n",
" 'dupform.pdf',\n",
" 'DVD.csv',\n",
" 'GermanCredit.csv',\n",
" 'Git Shell.lnk',\n",
" 'GitHub.appref-ms',\n",
" 'GoToMeeting.lnk',\n",
" 'groceries.csv',\n",
" 'Guidelines-CBSE.html',\n",
" 'IMS proschool',\n",
" 'iris2.csv',\n",
" 'logistic regression - script for ppt.R',\n",
" 'OnlineCardNSR.pdf',\n",
" 'PaymentForm.pdf',\n",
" 'Program 1-results.rtf',\n",
" 'Rdatasets',\n",
" 'Results_ Modeling and Forecasting.html',\n",
" 'Results_ Program 5.sas.html',\n",
" 'Results_ Time Series Exploration.ctk.html',\n",
" 'Rplot.png',\n",
" 'Rplot01.pdf',\n",
" 'Rplot02.pdf',\n",
" 'Rplot03.png',\n",
" 'rsconnect',\n",
" 'sas-university-edition-107140.pdf',\n",
" 'SQL-1.png',\n",
" 'sql.jpg',\n",
" 'sqlcheatsheet.jpg',\n",
" 'sqljoins_cheatsheet.png',\n",
" 'Sunstone - Google Docs.pdf',\n",
" 'test',\n",
" 'Trarscript_Form.pdf']"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.listdir()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [conda root]",
"language": "python",
"name": "conda-root-py"
},
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment