Created
October 4, 2018 03:48
-
-
Save kinverarity1/452374cc2934f2c3df1d221d407160f0 to your computer and use it in GitHub Desktop.
This file contains 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": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.22\n" | |
] | |
} | |
], | |
"source": [ | |
"import pandas as pd\n", | |
"import lasio\n", | |
"print(lasio.__version__)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df = pd.DataFrame({\n", | |
" 'curve1': [1, 2, 3, 4],\n", | |
" 'curve2': [10, 20, 30, 4]\n", | |
"})" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>curve1</th>\n", | |
" <th>curve2</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>1</td>\n", | |
" <td>10</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>2</td>\n", | |
" <td>20</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>3</td>\n", | |
" <td>30</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>4</td>\n", | |
" <td>4</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" curve1 curve2\n", | |
"0 1 10\n", | |
"1 2 20\n", | |
"2 3 30\n", | |
"3 4 4" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Index(['curve1', 'curve2'], dtype='object')" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df.columns" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Mnemonic Unit Value Description \n", | |
"-------- ---- ----- ----------- \n", | |
"curve1 \n", | |
"curve2 \n", | |
"UNKNOWN \n", | |
"\n", | |
"Curve data\n", | |
"[0 1 2 3]\n", | |
"[1 2 3 4]\n", | |
"[10 20 30 4]\n" | |
] | |
} | |
], | |
"source": [ | |
"las = lasio.LASFile()\n", | |
"\n", | |
"las.set_data(df, names=list(df.columns))\n", | |
"\n", | |
"print(las.curves)\n", | |
"\n", | |
"print('\\nCurve data')\n", | |
"for curve in las.curves:\n", | |
" print(curve.data)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Clearly an error due to the inclusion of the DataFrame index?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Mnemonic Unit Value Description \n", | |
"-------- ---- ----- ----------- \n", | |
"curve1 \n", | |
"curve2 \n", | |
"\n", | |
"Curve data\n", | |
"[1 2 3 4]\n", | |
"[10 20 30 4]\n" | |
] | |
} | |
], | |
"source": [ | |
"las = lasio.LASFile()\n", | |
"\n", | |
"las.set_data(df.values, names=list(df.columns))\n", | |
"\n", | |
"print(las.curves)\n", | |
"\n", | |
"print('\\nCurve data')\n", | |
"for curve in las.curves:\n", | |
" print(curve.data)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment