Posts

python - Plot average on subplots (pandas) -

Image
i've managed plot subplots groupby. have 2 columns 'a', , 'b', want plot on subplot (1 per value in 'b') respective averages. prepare data counting, dropping duplicates, , summing (if there more elegant way it, please let me know!). df = pd.dataframe([[1, 'cat1'], [1, 'cat1'], [4, 'cat2'], [3, 'cat1'], [5, 'cat1'],[1, 'cat2']], columns=['a', 'b']) df = df[['a','b']] df['count'] = df.groupby(['a','b'])['a'].transform('count') df = df.drop_duplicates(['a','b']) df = df.groupby(['a','b']).sum() then unstack , plot subplots: plot = df.unstack().plot(kind='bar',subplots=true, sharex=true, sharey=true, layout = (3,3), legend=false) plt.show(block=true) i add mean each category, have don't know: 1. how calculate mean. if calculate on unstacked groupby, mean of count, rather value 'a'....

android - Is it possible to call method in Activity class from Application class? -

i have defined public method in activity class (lets some_method()).is possible call method in application class. you can use singleton activity this: public class youractivity extends appcompatactivity { public static youractivity instance; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_layout); instance=this; //your code } //your method public void yourmethod() { } @override protected void ondestroy() { super.ondestroy(); instance=null; } } then in application method can call method of activity this: if (youractivity.instance != null) { youractivity.instance.yourmethod(); }

javascript - jQuery event doesn't work at new created element -

i take img element class ".follow", hide , replace new created element button class ".followbutton". after "mouseout" event take new created button element, hide , replace new created img element class ".follow". have new element img same atributes initially. "mouseenter" doesn't work. , don't figure out why. $(".follow") .on("mouseenter", function() { $(this).fadeout(150, function() { var init = this; var btn = document.createelement("button"); var t = document.createtextnode("follow"); btn.appendchild(t); btn.classname = "followbutton"; $(btn).hide(); $(this).replacewith(btn); $(".followbutton").show(150); $(".followbutton").on("mouseout", function() { var imgback = $("<img />"...

C# Google API (SheetsServices) Insert new row -

how can insert new row google spreadsheet. using google api (sheetsservices). class googleapi { // if modifying these scopes, delete saved credentials // @ ~/.credentials/sheets.googleapis.com-dotnet-quickstart.json static string[] scopes = { sheetsservice.scope.spreadsheets, "email" }; static string applicationname = "google sheets api .net quickstart"; public googleapi() { usercredential credential; using (var stream = new filestream("secret.json", filemode.open, fileaccess.read)) { string credpath = system.environment.getfolderpath( system.environment.specialfolder.personal); credpath = path.combine(credpath, ".credentials/secret.json"); credential = googlewebauthorizationbroker.authorizeasync( googleclientsecrets.load(stream).secrets, ...

R Shiny eventReactive actionBotton interaction -

Image
i have actionbotton randomly pick 1 column first 5 columns dataset mtcars , plot it. now actionbotton job chart not plotted @ first place when app launched. is there way have plotted when shiny app launched. library(shiny) server <- function(input, output) { x = eventreactive(input$plot,{ mtcars }) output$plot = renderplot({ = sample(1:5,1) plot(x()[,i],ylab=names(mtcars)[i]) }) } ui <- fluidpage( actionbutton("plot","randomly plot"), plotoutput("plot") ) shinyapp(ui = ui, server = server) you can add condition button hasn't been clicked. note button works counter if hasn't been clicked value 0. library(shiny) server <- function(input, output) { x = eventreactive(input$plot,{ mtcars }) output$plot = renderplot({ = sample(1:5,1) if(input$plot == 0){ return(plot(mtcars[,i],ylab=names(mtcars)[i])) } plot(x()[,i],ylab=names(mtcars)[i]) }) } ui <- fluidpa...

Prefered syntax for verilog module declaration -

i relatively new fpgas, , looking guidance modern best practice regarding declaration of modules in verilog. i have seen 2 ways of declaring module in verilog. first reminds me of traditional c , such examples on wikipedia : module toplevel(clock,reset); input clock; input reset; /* snip */ endmodule whereas alternative syntax has input/output specifier part of argument list, not dissimilar vhdl, in this example : module fadder( input a, //data in input b, //data in b input cin, //carry in output sum_out, //sum output output c_out //carry output ); /* snip */ endmodule for newly written verilog code, syntax preferred? "preferred", in instance, means written in standard or related material (either explicitly written, or implicitly examples given in standard), or written in well-regarded style guide. question isn't asking personal preference! the second syntax form indented replace first s...

SMS Gateway to send and receive sms in Nigeria -

please me , suggest me sms gateways provide 2 way sms in nigeria. have created web application. need send , receive sms through application , maintain log same in db. thanks you can use twilio sms gateway. url: https://www.twilio.com/sms , https://www.twilio.com/sms/pricing/ng