Read ini config file in Python
import configparser config = configparser.ConfigParser() config.read('example.ini') config['DEFAULT']['Compression']
References
https://docs.python.org/3/library/configparser.html
import configparser config = configparser.ConfigParser() config.read('example.ini') config['DEFAULT']['Compression']
References
https://docs.python.org/3/library/configparser.html
import ntpath import os filename = "templates - original/001.png" print(ntpath.basename(filename)) print(os.path.basename(filename)) print(os.path.split(filename)) print(os.path.splitext(filename)) print(os.path.splitext(os.path.basename(filename))) print(os.path.splitext(os.path.basename(filename))[0])
output
001.png 001.png ('templates - original', '001.png') ('templates - original/001', '.png') ('001', '.png') 001
# import pandas package as pd import pandas as pd # Define a dictionary containing students data data = {'Name': ['Ankit', 'Amit', 'Aishwarya', 'Priyanka'], 'Age': [21, 19, 20, 18], 'Stream': ['Math', 'Commerce', 'Arts', 'Biology'], 'Percentage': [88, 92, 95, 70]} # Convert the dictionary into DataFrame df = pd.DataFrame(data, columns = ['Name', 'Age', 'Stream', 'Percentage']) print("Given Dataframe :\n", df) print("\nIterating over rows using iterrows() method :\n") # iterate through each row and select # 'Name' and 'Age' column respectively. for index, row in df.iterrows(): print (row["Name"], row["Age"])
References
https://www.geeksforgeeks.org/different-ways-to-iterate-over-rows-in-pandas-dataframe/
import pandas as pd
excel_file = 'movies.xls' movies = pd.read_excel(excel_file)
movies_sheet1 = pd.read_excel(excel_file, sheetname=0, index_col=0)
p.title.text = title p.title_location = "above"
References
http://docs.bokeh.org/en/1.3.2/docs/user_guide/styling.html#title
p = figure(width=300, height=300, x_axis_label='Initial xlabel') p.xaxis.axis_label = 'New xlabel'
References
https://stackoverflow.com/questions/24131501/x-and-y-axis-labels-for-bokeh-figure
set FLASK_APP=app.py set FLASK_ENV=development REM set FLASK_ENV=production set FLASK_DEBUG=TRUE venv\Scripts\python.exe -m flask run --host=0.0.0.0 --port=14002
References
https://flask.palletsprojects.com/en/1.1.x/quickstart/
https://flask.palletsprojects.com/en/1.0.x/cli/
https://flask.palletsprojects.com/en/1.1.x/config/
https://stackoverflow.com/questions/29882642/how-to-run-a-flask-application
p.sizing_mode = "scale_both"
References
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html#sizing-mode
Embedding a single plot at a time with output_file()
<iframe src="/assets/img/Bokeh/flowers.html" sandbox="allow-same-origin allow-scripts" width="100%" height="500" scrolling="no" seamless="seamless" frameborder="0"> </iframe>
References
https://p-mckenzie.github.io/2017/12/01/embedding-bokeh-with-github-pages/
from flask import Flask from flask_cors import CORS, cross_origin app = Flask(__name__) cors = CORS(app) app.config['CORS_HEADERS'] = 'Content-Type' @app.route("/") @cross_origin() def helloWorld(): return "Hello, cross-origin-world!"
References
https://stackoverflow.com/questions/25594893/how-to-enable-cors-in-flask