Styleframe throws a numpy error in python
up vote
0
down vote
favorite
My code works fine for the first run which creates the base excel file, but when i run it the second time to add one more row to the file it throws an error.
What could be the reason?
Is it a handling error in styleframe module or do i have to pass the data frame in a different manner for it to process properly
import pandas as pd
import os
from StyleFrame import StyleFrame, Styler, utils
time_val='12oct 23:00'
league_name='sdvsv dvd ragf'
Team1_name='adfvdsr wvd'
Team2_name='dsvdwd rfb'
score_1='4'
score_2='2'
on_target_1='20'
on_target_2='34'
off_target_1='14'
off_target_2='12'
attacks_1='5'
attacks_2='7'
dattacks_1='12'
dattacks_2='23'
possesion_1='5'
possesion_2='61'
def write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,
dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,
possesion_1,possesion_2,score_1,score_2):
if os.path.exists(league_name+'.xlsx'):
df=pd.read_excel(league_name+'.xlsx')
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),
str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df.append(df2)
print(df)
print(df2)
print(new_df)
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
else:
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df2.copy()
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,possesion_1,possesion_2,score_1,score_2)
pandas styleframe
add a comment |
up vote
0
down vote
favorite
My code works fine for the first run which creates the base excel file, but when i run it the second time to add one more row to the file it throws an error.
What could be the reason?
Is it a handling error in styleframe module or do i have to pass the data frame in a different manner for it to process properly
import pandas as pd
import os
from StyleFrame import StyleFrame, Styler, utils
time_val='12oct 23:00'
league_name='sdvsv dvd ragf'
Team1_name='adfvdsr wvd'
Team2_name='dsvdwd rfb'
score_1='4'
score_2='2'
on_target_1='20'
on_target_2='34'
off_target_1='14'
off_target_2='12'
attacks_1='5'
attacks_2='7'
dattacks_1='12'
dattacks_2='23'
possesion_1='5'
possesion_2='61'
def write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,
dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,
possesion_1,possesion_2,score_1,score_2):
if os.path.exists(league_name+'.xlsx'):
df=pd.read_excel(league_name+'.xlsx')
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),
str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df.append(df2)
print(df)
print(df2)
print(new_df)
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
else:
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df2.copy()
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,possesion_1,possesion_2,score_1,score_2)
pandas styleframe
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My code works fine for the first run which creates the base excel file, but when i run it the second time to add one more row to the file it throws an error.
What could be the reason?
Is it a handling error in styleframe module or do i have to pass the data frame in a different manner for it to process properly
import pandas as pd
import os
from StyleFrame import StyleFrame, Styler, utils
time_val='12oct 23:00'
league_name='sdvsv dvd ragf'
Team1_name='adfvdsr wvd'
Team2_name='dsvdwd rfb'
score_1='4'
score_2='2'
on_target_1='20'
on_target_2='34'
off_target_1='14'
off_target_2='12'
attacks_1='5'
attacks_2='7'
dattacks_1='12'
dattacks_2='23'
possesion_1='5'
possesion_2='61'
def write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,
dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,
possesion_1,possesion_2,score_1,score_2):
if os.path.exists(league_name+'.xlsx'):
df=pd.read_excel(league_name+'.xlsx')
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),
str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df.append(df2)
print(df)
print(df2)
print(new_df)
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
else:
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df2.copy()
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,possesion_1,possesion_2,score_1,score_2)
pandas styleframe
My code works fine for the first run which creates the base excel file, but when i run it the second time to add one more row to the file it throws an error.
What could be the reason?
Is it a handling error in styleframe module or do i have to pass the data frame in a different manner for it to process properly
import pandas as pd
import os
from StyleFrame import StyleFrame, Styler, utils
time_val='12oct 23:00'
league_name='sdvsv dvd ragf'
Team1_name='adfvdsr wvd'
Team2_name='dsvdwd rfb'
score_1='4'
score_2='2'
on_target_1='20'
on_target_2='34'
off_target_1='14'
off_target_2='12'
attacks_1='5'
attacks_2='7'
dattacks_1='12'
dattacks_2='23'
possesion_1='5'
possesion_2='61'
def write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,
dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,
possesion_1,possesion_2,score_1,score_2):
if os.path.exists(league_name+'.xlsx'):
df=pd.read_excel(league_name+'.xlsx')
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),
str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df.append(df2)
print(df)
print(df2)
print(new_df)
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
else:
writer = pd.ExcelWriter(league_name+'.xlsx')
row=0
df2=pd.DataFrame([[time_val,league_name,Team1_name,str(score_1)+'-'+str(score_2),
Team2_name,str(on_target_1)+'-'+str(on_target_2),str(off_target_1)+'-'+str(off_target_2),str(attacks_1)+'-'+str(attacks_2),str(dattacks_1)+'-'+str(dattacks_2),
str(possesion_1)+'-'+str(possesion_2)],],
columns='Time,League,Team1,Score,Team2,Shots on target,Off target,Attacks,Dangerous attacks,Possesion'.split(','))
new_df=df2.copy()
sf2 = StyleFrame(new_df)
header_values=new_df.columns.tolist()
sf2.set_column_width(header_values,18)
sf2.apply_headers_style(styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#FFFF33',horizontal_alignment=utils.horizontal_alignments.center,bold=True,
border_type=utils.borders.medium))
sf2.apply_column_style(cols_to_style=header_values,styler_obj=Styler(font_size=8,wrap_text=False,shrink_to_fit=False,
bg_color='#DCDCDC',horizontal_alignment=utils.horizontal_alignments.center,
border_type=utils.borders.medium))
sf2.to_excel(writer,startrow=row , startcol=0,index=False).save()
write(time_val,league_name,Team1_name,Team2_name,attacks_1,attacks_2,dattacks_1,dattacks_2,on_target_1,on_target_2,off_target_1,off_target_2,possesion_1,possesion_2,score_1,score_2)
pandas styleframe
pandas styleframe
asked Nov 12 at 7:55
Channel chan
1
1
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41
add a comment |
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257880%2fstyleframe-throws-a-numpy-error-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257880%2fstyleframe-throws-a-numpy-error-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Fixed it, but not sure why the append would return a numpy array in the dataframe. Here is the code pastebin.com/H9mvGAfa
– Channel chan
Nov 12 at 9:41