本文整理汇总了Python中plotly.tools.FigureFactory.create_table方法的典型用法代码示例。如果您正苦于以下问题:Python FigureFactory.create_table方法的具体用法?Python FigureFactory.create_table怎么用?Python FigureFactory.create_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plotly.tools.FigureFactory
的用法示例。
在下文中一共展示了FigureFactory.create_table方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pretty_table
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def pretty_table(df, outfile=None):
"""
Display pandas dataframe as a nicely-formated HTML
Parameters
----------
outfile: filepath str
If provided, output to an HTML file at provided location
Example
-------
import pandas as pd
animals = pd.DataFrame([
['cat',10, 'housepet'],
['dog',20,'housepet'],
['fish',5,'housepet'],
['cat',20,'zooanimal'],
['dog',50,'zooanimal'],
['fish',20,'zooanimal'],], columns=['animal','value','group'])
pretty_table(animals)
"""
table = FF.create_table(df)
ol.iplot(table, show_link=False)
# write figure to HTML file
if outfile:
print('Exporting copy of figure to %s...' % outfile)
ol.plot(table, auto_open=False, filename=outfile)
示例2: plot_tables
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def plot_tables():
data_matrix_dem = [
['Feature', 'Coeff', 'Std Err', 'P Val'],
['State Average Turnout', 0.0048, 0.000, 0.000],
['Rural-urban Continuum Code', 0.0046, 0.000, 0.000],
['Perc Less than Highschool Diploma', 0.0006, 0.000, 0.000],
['Perc with Bachelor\'s', 0.0032, 8.54e-05, 0.000],
['Unemployment Rate', 0.0041, 0.000, 0.000],
['Religion NMF Feature 1', 0.0091, 0.001, 0.000],
['Religion NMF Feature 2', 0.0063, 0.000, 0.000],
['Campaign Expenditure', -4.084e-10, 5.09e-11, 0.000],
['Cook Index', 0.4752, 0.006, 0.000],
['Change in Vote Share 2008->2012', 0.2689, 0.024, 0.000],
['1 Field Office', 0.0088, 0.002, 0.000],
['2+ Field Offices', 0.0257, 0.004, 0.000],
['Field Office - Cook Index Interaction', 0.0348, 0.017, 0.041]
]
data_matrix_rep =[
['Feature', 'Coeff', 'Std Err', 'P Val'],
['State Average Turnout', 0.0060, 0.000, 0.000],
['Rural-urban Continuum Code', 0.0044, 0.000, 0.000],
['Perc Less than Highschool Diploma', -0.0024, 0.000, 0.000],
['Perc with Bachelor\'s', 0.0025, 0.000, 0.000],
['Unemployment Rate', 0.0054, 0.000, 0.000],
['Religion NMF Feature 1', 0.0003, 0.001, 0.700],
['Religion NMF Feature 2', 0.0072, 0.001, 0.000],
['Campaign Expenditure', -4.905e-10, 6.44e-11, 0.000],
['Cook Index', -0.5827, 0.008, 0.000],
['Change in Vote Share 2008->2012', -0.0543, 0.032, 0.000],
['1 Field Office', 0.0087, 0.004, 0.025],
['2+ Field Offices', 0.0143, 0.008, 0.080],
['Field Office - Cook Index Interaction', -.1054, 0.029, 0.000]
]
table_dem = FF.create_table(data_matrix_dem)
table_dem.layout.update({'title': 'Democratic Regression<br><i>Adj R2 0.978<i>'})
table_rep = FF.create_table(data_matrix_rep)
table_rep.layout.update({'title': 'Republican Regression<br><i>Adj R2 0.982<i>'})
# fig = tools.make_subplots(rows=1, cols=2, subplot_titles=('Democratic Regression<br><i>Adj R2 0.978<i>',
# 'Republican Regression<br><i>Adj R2 0.982<i>'))
plot_url = py.plot(table_dem, filename='Dem Regression Results')
plot_url = py.plot(table_rep, filename='Rep Regression Results')
示例3: build_plotly_table
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def build_plotly_table(plotly_df):
plotly_df = plotly_df[['Passer_Name', 'Receiver_Name', 'Assists']]
plotly_df = plotly_df.sort_values(by='Assists', ascending=False)
plotly_df = plotly_df.head(25)
plotly_df.columns = ['Passer', 'Receiver', 'Assists']
plotly_df = plotly_df.as_matrix()
plotly_df = np.insert(plotly_df, 0, np.array(('Passer', 'Receiver', 'Assists')), 0)
table = FF.create_table(plotly_df)
py.iplot(table, filename='assist_pairs')
示例4: search
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def search(self, data_rows, key):
data = data_rows[0]
if key == 'searchUser':
data_matrix = [['Username', 'Count'],
[data[0], data[1]]]
elif key == 'searchSubred':
data_matrix = [['Subreddit', 'Count'],
[data[0], data[1]]]
colorscale = [[0, '#4d004c'], [.5, '#ffffff'], [1, '#f2e5ff']]
table = FF.create_table(data_matrix, colorscale=colorscale)
plotted = plotly.offline.plot(table, filename='../graphs.html')
return plotted
示例5: make_test_plot
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def make_test_plot():
# Add table data
table_data = [['Team', 'Wins', 'Losses', 'Ties'],
['Montreal<br>Canadiens', 18, 4, 0],
['Dallas Stars', 18, 5, 0],
['NY Rangers', 16, 5, 0],
['Boston<br>Bruins', 13, 8, 0],
['Chicago<br>Blackhawks', 13, 8, 0],
['Ottawa<br>Senators', 12, 5, 0]]
# Initialize a figure with FF.create_table(table_data)
figure = FF.create_table(table_data, height_constant=60)
# Add graph data
teams = ['Montreal Canadiens', 'Dallas Stars', 'NY Rangers',
'Boston Bruins', 'Chicago Blackhawks', 'Ottawa Senators']
GFPG = [3.54, 3.48, 3.0, 3.27, 2.83, 3.18]
GAPG = [2.17, 2.57, 2.0, 2.91, 2.57, 2.77]
# Make traces for graph
trace1 = go.Bar(x=teams, y=GFPG, xaxis='x2', yaxis='y2',
marker=dict(color='#0099ff'),
name='Goals For<br>Per Game')
trace2 = go.Bar(x=teams, y=GAPG, xaxis='x2', yaxis='y2',
marker=dict(color='#404040'),
name='Goals Against<br>Per Game')
# Add trace data to figure
figure['data'].extend(go.Data([trace1, trace2]))
# Edit layout for subplots
figure.layout.yaxis.update({'domain': [0, .45]})
figure.layout.yaxis2.update({'domain': [.6, 1]})
# The graph's yaxis2 MUST BE anchored to the graph's xaxis2 and vice versa
figure.layout.yaxis2.update({'anchor': 'x2'})
figure.layout.xaxis2.update({'anchor': 'y2'})
figure.layout.yaxis2.update({'title': 'Goals'})
# Update the margins to add a title and see graph x-labels.
figure.layout.margin.update({'t':75, 'l':50})
figure.layout.update({'title': '2016 Hockey Stats'})
# Update the height because adding a graph vertically will interact with
# the plot height calculated for the table
figure.layout.update({'height':800})
# Plot!
return plotly.offline.plot(figure, output_type='div')
示例6: generate
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def generate():
# Add table data
global data
global internet_data_list
data = lp.all_running_process()
#print data
table_data = transform_program_data('table')
# Initialize a figure with FF.create_table(table_data)
figure = FF.create_table(table_data, height_constant=60, index=True)
pyChart1 = go.Pie(labels = ['tumblr', 'twitter', 'facebook', 'pinterest'],
values = internet_data_list,
name = 'Internet',
hole = .4,
domain = {'x':[0, .48], 'y':[1, .55]})
pyChart2 = go.Pie(labels = transform_program_data('pyName'),
values = transform_program_data('pyData'),
name = 'Programs',
hole = .4,
domain = {'x':[.52, 1], 'y':[1, .55]})
# Add trace data to figure
figure['data'].extend(go.Data([pyChart1]))
figure['data'].extend(go.Data([pyChart2]))
#Table goes at bottom of plot
figure.layout.yaxis.update({'domain': [0, .45]})
# Update the margins to add a title and see graph x-labels.
figure.layout.margin.update({'t':75, 'l':50})
figure.layout.update({'title': 'How I\'m Spending My Time'})
figure.layout.update({'height':800, 'width':1000})
# Plot!
plotly.offline.plot(figure, filename='pyChartWithTable.html', auto_open=False)
示例7: make_table
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def make_table(self, context, title, df):
""" generating table"""
fig = FF.create_table(df)
plot(self, fig)
示例8: range
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
return go.Figure(data=data, layout=layout)
## Chart
date_start = '2013-10-01'
py.image.save_as(gen_chart(df_con_qoq[['GDP', "Net Investment"]], "2QGDP", "QoQsa", date_start),
"../exhibits/categories_sa.jpeg", format="jpeg")
## Table
vtable = df_con_qoq.tail(2).T
table_data = np.concatenate((vtable.index.values.reshape(9,1),
np.round(vtable.values, decimals=2)), axis=1)
table_output = np.concatenate((np.array(['Component', "1Q2016 (qoqsa%)",
'2Q2016 (qoqsa%)']).reshape(1,3), table_data), axis=0)
color_font_row = ["00000" for i in range(0, 10)]
color_font_row[0] = "#ffffff"
color_font_row[4] = 'red'
table = FF.create_table(table_output, font_colors = color_font_row)
for i in range(len(table.layout.annotations)):
table.layout.annotations[i].font.size = 15.5
py.image.save_as(table, filename= "../exhibits/table_gdp_sa_categories.jpeg", format='jpeg')
## Carry over
df_carry = pd.DataFrame(index= ['2016-04-10', '2016-07-01','2016-10-01'])
df_carry['GDP'] = df['GDP'].tail(1).values[0]
df_carryover = pd.concat([pd.DataFrame(df['GDP']), df_carry]).rolling(window=4).sum().pct_change(periods=4)*100
df_carryover.tail(1)
示例9: create_table
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
def create_table(data_df):
table = FF.create_table(table_df,index=True, index_title='Date')
py.iplot(table, filename='crude_table')
示例10: round
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
df_data_Q4['Russell 3000'] = df_data_other[Q4].mean(axis=1)
# Calculate the Rolling Correlation with all funds and different quartile
rolling_corr_df_other = m.rolling_corr(df_data_corr, columns_name, market_index, window_length_corr, min_periods_corr)
rolling_corr_df_Q1 = m.rolling_corr(df_data_Q1, columns_name, market_index, window_length_corr, min_periods_corr)
rolling_corr_df_Q2 = m.rolling_corr(df_data_Q2, columns_name, market_index, window_length_corr, min_periods_corr)
rolling_corr_df_Q3 = m.rolling_corr(df_data_Q3, columns_name, market_index, window_length_corr, min_periods_corr)
rolling_corr_df_Q4 = m.rolling_corr(df_data_Q4, columns_name, market_index, window_length_corr, min_periods_corr)
### Plotly Table ###
py.sign_in('fzn0728', '1enskD2UuiVkZbqcMZ5K')
## py.sign_in('fzn07289', 'TMIrmI4FoHE7W5VHKgTQ')
# Annual Return Table
Annulized_Return_df = round(100*Annulized_Return_df,2)
table_Annulized_Return = FF.create_table(Annulized_Return_df, index=True)
py.plot(table_Annulized_Return, filename='Table 1 Annualized Return')
# Annual Return Plot
trace1 = go.Scatter(
x=rolling_annual_return_df.index,
y=100*rolling_annual_return_df['A'],
name='A'
)
trace2 = go.Scatter(
x=rolling_annual_return_df.index,
y=100*rolling_annual_return_df['B'],
name='B'
)
trace3 = go.Scatter(
x=rolling_annual_return_df.index,
y=100*rolling_annual_return_df['C'],
示例11: Flask
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
from plotly.tools import FigureFactory as FF
import json
import pandas as pd
import numpy as np
app = Flask(__name__)
app.debug = True
df = pd.read_csv("data/bank.csv", sep=";")
res = pd.DataFrame({"Relative score":[100,85,73,70,60], "Predictor":["marital","education","job","balance","loan"] })
table = FF.create_table(res)
@app.route('/')
def index():
churn = [Scatter(x=range(4), y=[10,11,12,13], mode="markers", marker=dict(size=[40,60,80,100]), name = "High CLV")
,Scatter(x=range(4), y=[13.4,9,7,5], mode="markers", marker=dict(size=[50,70,90,110]), name = "Medium CLV")
,Scatter(x=range(4), y=[8,11,10,7], mode="markers", marker=dict(size=[30,40,50,60]), name = "Low CLV")
]
## Histograms of 'important' variables
marital = [Histogram(x=np.array(df.query('y=="yes"').ix[:,'marital']), name='Took loan'),
Histogram(x=np.array(df.query('y=="no"').ix[:,'marital']), name='Rejected loan')]
示例12: open
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
]
# Adding Rows to Catagorical Table
cat_data_matrix = [catHeaders,
catRows[0],
catRows[1],
catRows[2],
catRows[3],
catRows[4],
catRows[5],
catRows[6],
catRows[7],
catRows[8]
]
cont_table = FF.create_table(cont_data_matrix, index= True,index_title='FeatureName')
cat_table = FF.create_table(cat_data_matrix, index= True,index_title='FeatureName')
#==============================================================================
#Comma Seperated Output Files
#==============================================================================
contCSV = open('.\data\C11483622CONT.csv', 'w')
wr = csv.writer(contCSV, quoting=csv.QUOTE_ALL)
wr.writerow(contHeaders)
wr.writerows(contRows)
contCSV.flush()
contCSV.close()
catCSV = open('.\data\C11483622CAT.csv', 'w')
wr2 = csv.writer(catCSV, quoting=csv.QUOTE_ALL)
示例13: sum
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
manufacturers.append(brandon[32:len(brandon)-2])
if "Nmap scan" in brandon:
ips.append(brandon[15:len(brandon)-1])
num_lines = sum(1 for line in open('NMAP1.txt'))
file1 = open('NMAP1.txt', 'r')
x = []
y = []
for q in xrange(num_lines/2-1):
x.append(file1.readline())
y.append((int)(file1.readline()))
trace = go.Scatter(
x = x,
y = y
)
data = [trace]
py.plot(data, filename='basic-line', auto_open=False)
data_matrix = [['Manufacturer', 'IP Address', 'MAC Address'],
]
p = 0
for x in macs:
data_matrix.append([manufacturers[p], ips[p], macs[p]])
p += 1
table = FF.create_table(data_matrix)
py.plot(table, filename='simple_table', auto_open=False)
@app.route('/')
def index():
return 'BG'
if __name__ == '__main__':
app.run(host='0.0.0.0')
示例14:
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import create_table [as 别名]
import plotly.plotly as pty
import process as pr
import statistics as stat
from plotly.tools import FigureFactory
pty.sign_in("Chiibi", "lm7ftxursd")
data = pr.reader()
data_matrix = [['Games', 'Average', 'Ceiling', 'Floor', 'SD']] + [[i[0], '{0:,.2f}'.format(stat.mean(i[1])), '{0:,d}'.format(max(i[1])), '{0:,d}'.format(min(i[1])), '{0:,.2f}'.format(stat.stdev(i[1]))] for i in data]
table = FigureFactory.create_table(data_matrix, index=True)
url = pty.plot(table, filename='data_table')