Posts

Showing posts with the label for-loop

Searching for element in a column by iterating over the column, pandas

Searching for element in a column by iterating over the column, pandas In my data frame I need to remove columns that contain a specific character. In order to search for those columns, I am trying to write a for loop in python that iterate over each column and, if find a column with the unwanted character, this column has to be dropped out. My data frame appears like this and I need to drop col3 and col5 that have 'f' and 't' col1 col2 col3 col4 col5 col6 1245 pink f Mar f f 245 green f Feb t f 1237 grey t Apr f f 267 black f Sep t f I am trying to write a script similar to this for col in df.items(): if df[col] == 'f' df = df.drop([col], axis=1) Does the column 6 have to stay? – Joe 1 min ago 2 Answers ...

AS3: Adding function to population loop

AS3: Adding function to population loop Basically I have 2 movieclip objects with some code, currently just to trace them. The blue circles when clicked will say 'Blue' and the red ones when clicked will say 'Red'. This works fine in theory until I add a population loop, which adds more of them. Then only 1 of each colour correctly works, the rest are just 'mock' circles. I wish for each circle to tell me their colour. This is my code for the .fla: import flash.events.MouseEvent; BlueBall.addEventListener(MouseEvent.CLICK, fun1) function fun1(e:MouseEvent){ trace("Blue!"); } RedBall.addEventListener(MouseEvent.CLICK, fun2) function fun2(e:MouseEvent){ trace("Red!"); } and this is the population loop in an .as file: private function PopulateCircles():void { for (var i:int=0; i < 10; i++) { var blueCircle:BlueCircle = new BlueCircle(); this.addChild(blueCircle); var redCircle:RedCircle = new RedCircle(...

For loop in VBA when refreshing Bloomberg requests

For loop in VBA when refreshing Bloomberg requests I am putting together an excel workbook that performs various calculations based on a number of Bloomberg fields. For a particular date, it checks various requirements and then outputs either a 1 or -1 in a row based on if the requirements are met or not. I have got this working with a macro. The issue is I need to run the checks through a number of dates. So each loop I need the input date to be changed, the Bloomberg data needs to refresh and then either put a 1 or -1 in the next row down based on if requirements are met for this date. The problem is I can not get the loop to work correctly. Below is a simplified version of my code: Public i As Integer Public Sub RefreshStaticLinks() Call Worksheets("Sheet2").Range("A5:H7").Select Call Application.Run("RefreshCurrentSelection") Call Application.OnTime(Now + TimeValue("00:00:10"), "ProcessData") End Sub Private Sub ProcessD...

Finding frequent itemsets with Apriori Algorithm?

Finding frequent itemsets with Apriori Algorithm? I am trying to code the apriori algorithm in Java but am facing a problem regarding frequent itemsets. My mininum support is 1% -> each of the itemsets must be in one or more transactions. In order to understand the algorithm, ive started with cardinality 1. Now the more transactions I compute the less correct my implementation gets though it works with less than 4 transactions. private static void checkForFrequentItemSet() { ArrayList<String> transactions = collectTransactions(); ArrayList<String> items = createItemList(); // First Iteration actually, C1 int k = 1; // while(!items.isEmpty()) // { items = generateCandidates(items, k); System.out.println("There are exactly " + items.size() + " frequent itemsets containing " + k + " item(s):"); System.out.println(items);// Remember this is c1 at first iteration k++; ArrayList<String> finalItems = ne...

How to check if an item in an ArrayList does not contain a certain word?

How to check if an item in an ArrayList<String> does not contain a certain word? I want to use a for loop like this: `button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Object.setList(); for(int i = 0; i < Object.getList.size(); i++) if(!Object.getList.get(i).trim().toLowerCase().contains("hello")) { Toast.makeText(getContext(), "List does not contain "Hello", Toast.LENGTH_LONG).show; } }` This is my model: public class Object { private ArrayList<String> mArrayList; public void setList() { mArrayList = new Arraylist<>(); mArrayList.add("Random Message"); mArrayList.add("ZZZZ") } public ArrayList<String> getList() { return mArrayList; } } I still keep getting the Toast message, but it works just fine when i use: if(!Object.getList().toString.trim().toLowerCase().contains("hello")) ...