Posts

 I found a very strange anamoly of a code working on Jupyter notebook, but its not working on the app.python from a flask applicatoin. When the type of column names if int instead of string, the str.replace() code works on the jupyter notebook, but does not work in the flask python. Scenario: I have a dataframe having year-months(For example 202001, 202002 etc.) as the column name. Now I want to have a replace code, like, col = [ '201911', '201912','202001', '202002', '202003', '202004', '202005', '202006', '202007', '202008','202009','202010']  the below code works on the jupyter notebook, but fails on the flask. data_df[col] = data_df[col].replace(to_replace=['-',' ','\*'], value='', regex=True).astype(float)
Selecting rows of a dataframe based on value/string pattern in a column Comparing a string pattern with values in a column of a pandas DataFrame. Many times i have seen that, x_df.loc[x_df.column_A == "xyz",:] fails to return the rows which contain "xyz" in the column_A of Data Frame x_df Its always better to use below code for this task of selecting rows where column_A has "xyz" as its value, x_df[x_df['column_A'].str.contains("xyz")]
'Sum' with Groupby() on a column in pandas. ====================================================== When we use aggregation function 'sum' on the result of groupby() on a column as below. x_df.groupby(['Column1']).sum() If there are multiple columns in data frame x_df. Only those columns will come in the result which are of type "float". If there are columns, where type of elements are of type "int", it will not come in the result if above code. Check the type of elements of columns if any column is not coming in the result.
when we use "apply" with a custom function with "groupby" on a pandas data frame. the customer function inside the apply() gets called twice. this is by design of pandas. Issue in the pandas. https://github.com/pandas-dev/pandas/issues/2656 My question related to this issue on stackoverflow, https://stackoverflow.com/questions/53698605/all-columns-are-not-passed-when-we-use-apply-on-result-of-groupby-with-a-custom

Reading CSVs through pandas containing Japanese character in some columns.

When we use pandas.read_csv(encoding = "utf8") to read a csv which contains both English and Japanese character, it fails with the error, "UTF-8 codec can not decode byte..... " Please use pandas.read_csv(encoding = "cp932") in this case. It works with a warning
Making an Asynchronous call inside a for loop in Angular 2 ------------------------------------------------------------------------ One of the frustrating problems of Angular 2, is that when you call an asynchronous method inside a for loop. It happens that, before the call returns for 1st iteration, the second iteration is called and this messes up the value of variables. Solution: One should use the flatMap here, to make sure that call from 2nd iteration does not happen unless call returns and completes for the 1st iteration. Observable . of ( localListID ). flatMap (( ellistId ) => ellistId ). subscribe (( pData ) => { //Make asynchronous call here, using pData. } Here localListID is array, and we want to use elements of this array to make asynchronous calls.
Some Html Issues faced while working with Angular 2. Checkbox not getting selected on Screen. --------------------------------------------------          Soultion: Changed the z-index of checkbox and moved it to the front. Only one checkbox getting selected. --------------------------------------------------         Solution: Added a handler on the click, sent the event to the handler, and called event.stopPropagation() inside handler.