8000 Létrehozva a Colaboratory használatával · klajosw/python@ebd08c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ebd08c0

Browse files
committed
Létrehozva a Colaboratory használatával
1 parent 60a2942 commit ebd08c0

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

kl_py_pandas_xls_chart.ipynb

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"id": "view-in-github",
7+
"colab_type": "text"
8+
},
9+
"source": [
10+
"<a href=\"https://colab.research.google.com/github/klajosw/python/blob/master/kl_py_pandas_xls_chart.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"metadata": {
16+
"id": "R5ZZP4ewA8mP"
17+
},
18+
"source": [
19+
"<p align=\"left\"> \n",
20+
" <img src=\"https://raw.githubusercontent.com/klajosw/python/master/kl_mie_python_logo_250.jpg\" \n",
21+
" align=\"left\" width=\"251\" height=\"251\">\n",
22+
" \n",
23+
"</p>\n",
24+
"\n",
25+
"\n",
26+
"<p> </p>\n",
27+
"\n",
28+
"# Riportok Excelbe mentése és diagram készítés \n",
29+
"\n",
30+
"## Pandas csomag használatával\n",
31+
"\n",
32+
"https://klajosw.blogspot.com/\n",
33+
"\n",
34+
"https://github.com/klajosw/\n",
35+
"\n",
36+
"---"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"id": "Ekvj4iSxA8mV"
44+
},
45+
"outputs": [],
46+
"source": [
47+
"import pandas as pd\n",
48+
"from pandas import ExcelWriter\n",
49+
"from pandas import ExcelFile\n",
50+
"import datetime\n",
51+
"import matplotlib.pyplot as plt \n",
52+
"\n",
53+
"\n",
54+
"dt = datetime.datetime.now() - datetime.timedelta(days=1) ## tegnapi nap\n",
55+
"datum = '{:%Y-%m-%d}'.format(dt)\n",
56+
"\n",
57+
"# minta adat generálás\n",
58+
"dojo_1 = {'Pyton': 20, 'Java': 19, 'C#': 21, 'JS': 13, 'HTML': 18}\n",
59+
"dojo_2 = {'Pyton': 25, 'Java': 22, 'C#': 20, 'JS': 17, 'HTML': 10}\n",
60+
"dojo_3 = {'Pyton': 27, 'Java': 17, 'C#': 12, 'JS': 14, 'HTML': 23}\n",
61+
"dojo_4 = {'Pyton': 24, 'Java': 20, 'C#': 15, 'JS': 15, 'HTML': 11}\n",
62+
"\n",
63+
"# adat és index összeállítás\n",
64+
"data = [dojo_1, dojo_2, dojo_3, dojo_4]\n",
65+
"index = ['Dojo 1', 'Dojo 2', 'Dojo 3', 'Dojo 4']\n",
66+
"\n",
67+
"# Pandas dataframe létrehozása minta adatokból\n",
68+
"df = pd.DataFrame(data, index=index)\n",
69+
"\n",
70+
"#Excel objektum létrehozása\n",
71+
"writer = pd.ExcelWriter(r'kl_dojo_'+datum+'_kesz.xlsx')\n",
72+
"df.to_excel(writer, sheet_name='Munka1', engine='xlsxwriter')\n",
73+
"\n",
74+
"#munka fizet és munkalap létrehozása\n",
75+
"workbook = writer.book\n",
76+
"worksheet = writer.sheets['Munka1']\n",
77+
"\n",
78+
"#diagram készítése\n",
79+
"chart = workbook.add_chart({'type': 'column'})\n",
80+
"\n",
81+
"# adat betöltés ciklus\n",
82+
"for col_num in range(1, len(dojo_1) + 1):\n",
83+
" chart.add_series({\n",
84+
" 'name': ['Munka1', 0, col_num],\n",
85+
" 'categories': ['Munka1', 1, 0, 4, 0],\n",
86+
" 'values': ['Munka1', 1, col_num, 4, col_num],\n",
87+
" 'overlap':-10,\n",
88+
" })\n",
89+
" \n",
90+
" \n",
91+
"# konfigurálása adiagrammnak\n",
92+
"chart.set_x_axis({'name': 'Total Dojo'})\n",
93+
"chart.set_y_axis({'name': 'Dojo', 'major_gridlines': {'visible': False}})\n",
94+
"\n",
95+
"# diagram munkalap cellába helyezése\n",
96+
"worksheet.insert_chart('H2', chart)\n",
97+
"\n",
98+
"\n",
99+
"# Az excel állomány mentése, lezárás\n",
100+
"writer.save()\n",
101+
"# writer.close()\n",
102+
"\n",
103+
"#plt.plot(df)\n",
104+
"df.plot(kind='bar', color=['red','blue','green','orange','yellow'])\n",
105+
"df.plot(kind='line', color=['red','blue','green','orange','yellow'])\n",
106+
"df.plot(kind='bar', color=['red','blue','green','orange','yellow'])\n",
107+
"df.plot(kind='barh',color=['red','blue','green','orange','yellow'])\n",
108+
"df.plot(kind='hist', color=['red','blue','green','orange','yellow'])\n",
109+
"df.plot(kind='area', color=['red','blue','green','orange','yellow'])"
110+
]
111+
}
112+
],
113+
"metadata": {
114+
"accelerator": "GPU",
115+
"colab": {
116+
"collapsed_sections": [],
117+
"name": "kl_py_pandas_xls_chart.ipynb",
118+
"private_outputs": true,
119+
"provenance": [],
120+
"toc_visible": true,
121+
"include_colab_link": true
122+
},
123+
"kernelspec": {
124+
"display_name": "Python 3",
125+
"language": "python",
126+
"name": "python3"
127+
},
128+
"language_info": {
129+
"codemirror_mode": {
130+
"name": "ipython",
131+
"version": 3
132+
},
133+
"file_extension": ".py",
134+
"mimetype": "text/x-python",
135+
"name": "python",
136+
"nbconvert_exporter": "python",
137+
"pygments_lexer": "ipython3",
138+
"version": "3.8.8"
139+
}
140+
},
141+
"nbformat": 4,
142+
"nbformat_minor": 0
143+
}

0 commit comments

Comments
 (0)
0