Skip to content

Commit fc007e3

Browse files
committed
converted the pandas.rst file as a Jupyter notebook
1 parent 7fea900 commit fc007e3

File tree

4 files changed

+199
-17
lines changed

4 files changed

+199
-17
lines changed

doc/source/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ It is mainly dedicated to help new users to familiarize with it and others to re
2222
./tutorial/tutorial_plotting.ipynb
2323
./tutorial/tutorial_miscellaneous.ipynb
2424
./tutorial/tutorial_sessions.ipynb
25-
./tutorial/pandas.rst
25+
./tutorial/pandas.ipynb

doc/source/tutorial/pandas.ipyml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
cells:
2+
3+
- markdown: |
4+
# Compatibility with pandas
5+
6+
7+
- code: |
8+
# run this cell to avoid annoying warnings
9+
import warnings
10+
warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
11+
12+
metadata:
13+
nbsphinx: hidden
14+
15+
- markdown: |
16+
Import the LArray library:
17+
18+
19+
- code: |
20+
from larray import *
21+
22+
23+
- markdown: |
24+
Check the version of LArray:
25+
26+
27+
- code: |
28+
from larray import __version__
29+
__version__
30+
31+
32+
- markdown: |
33+
To convert an Array object into a pandas DataFrame, the method [to_frame](../_generated/larray.Array.to_frame.rst#larray.Array.to_frame) can be used:
34+
35+
36+
- code: |
37+
pop = load_example_data('demography_eurostat').pop
38+
pop
39+
40+
41+
- code: |
42+
df = pop.to_frame()
43+
df
44+
45+
46+
- markdown: |
47+
Inversely, to convert a DataFrame into an Array object, use the function [asarray](../_generated/larray.asarray.rst#larray.asarray):
48+
49+
50+
- code: |
51+
pop = asarray(df)
52+
pop
53+
54+
55+
# The lines below here may be deleted if you do not need them.
56+
# ---------------------------------------------------------------------------
57+
metadata:
58+
celltoolbar: Edit Metadata
59+
kernelspec:
60+
display_name: Python 3
61+
language: python
62+
name: python3
63+
language_info:
64+
codemirror_mode:
65+
name: ipython
66+
version: 3
67+
file_extension: .py
68+
mimetype: text/x-python
69+
name: python
70+
nbconvert_exporter: python
71+
pygments_lexer: ipython3
72+
version: 3.7.3
73+
nbformat: 4
74+
nbformat_minor: 2
75+

doc/source/tutorial/pandas.ipynb

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Compatibility with pandas"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"nbsphinx": "hidden"
15+
},
16+
"outputs": [],
17+
"source": [
18+
"# run this cell to avoid annoying warnings\n",
19+
"import warnings\n",
20+
"warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"metadata": {},
26+
"source": [
27+
"Import the LArray library:"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"from larray import *"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"Check the version of LArray:"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {},
50+
"outputs": [],
51+
"source": [
52+
"from larray import __version__\n",
53+
"__version__"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"metadata": {},
59+
"source": [
60+
"To convert an Array object into a pandas DataFrame, the method [to_frame](../_generated/larray.Array.to_frame.rst#larray.Array.to_frame) can be used:"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"pop = load_example_data('demography_eurostat').pop\n",
70+
"pop"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"df = pop.to_frame()\n",
80+
"df"
81+
]
82+
},
83+
{
84+
"cell_type": "markdown",
85+
"metadata": {},
86+
"source": [
87+
"Inversely, to convert a DataFrame into an Array object, use the function [asarray](../_generated/larray.asarray.rst#larray.asarray):"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": null,
93+
"metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"pop = asarray(df)\n",
97+
"pop"
98+
]
99+
}
100+
],
101+
"metadata": {
102+
"celltoolbar": "Edit Metadata",
103+
"kernelspec": {
104+
"display_name": "Python 3",
105+
"language": "python",
106+
"name": "python3"
107+
},
108+
"language_info": {
109+
"codemirror_mode": {
110+
"name": "ipython",
111+
"version": 3
112+
},
113+
"file_extension": ".py",
114+
"mimetype": "text/x-python",
115+
"name": "python",
116+
"nbconvert_exporter": "python",
117+
"pygments_lexer": "ipython3",
118+
"version": "3.7.3"
119+
}
120+
},
121+
"nbformat": 4,
122+
"nbformat_minor": 2
123+
}

doc/source/tutorial/pandas.rst

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)