Categories
Mastering Development

Pandas advanced column creation from another dataframe

I have a dataframe like below: df_detail = car_brand car_type 0 Toyota Sedan 1 Toyota Truck 2 Honda Truck 3 Mazda Sedan 4 Mazda Convertible I want to create a summary dataframe like below: df_summary= ID car_brand count_Sedan count_Truck count_Convertible 0 Toyota 1 1 0 1 Honda 0 1 0 2 Mazda 1 0 1 […]

Categories
Mastering Development

show elements of array with determined value first

I have this array: $array = [ [‘brand’ => ‘bmw’, ‘type’ => ‘car’], [‘brand’ => ‘yahaha’, ‘type’ => ‘bike’], [‘brand’ => ‘specialized’, ‘type’ => ‘bycicle’], [‘brand’ => ‘toyota’, ‘type’ => ‘car’], [‘brand’ => ‘honda’, ‘type’ => ‘bike’] ] How can i show the ‘cars’ first and then all the others? i’m going nuts. something like […]

Categories
Mastering Development

add a column to a dataframe in r based on unique values row count

I have a consolidated table as given below: > dput(data.frame(df)) structure(list(make = c("audi", "audi", "audi", "audi", "bmw", "bmw", "toyota", "toyota", "toyota", "honda", "honda", "honda", "honda"), model = c("A3", "A3", "A4", "A4", "3 Series", "3 Series", "Land Cruiser", "Camry", "Camry", "Accord", "Accord", "civic", "civic"), variant = c("1.4L TFSI", "1.6L TFSI", "1.6L", "1.8L TFSI Quattro", "320d", "320d", […]

Categories
Mastering Development

when Build Dynamic query Error display converting data type varchar to float How to solve it?

I work on SQL server 2012 when Build dynamic Query I get error Msg 8114, Level 16, State 5, Line 16 Error converting data type varchar to float. so How to solve this Error ? I build dynamic query based on @Header and @column and @Body . @Header represent header must display as Headers . […]

Categories
Mastering Development

Issue on Updating URL Window History based on Multi Groups of Checkboxes

Can you please take a look at this code and let me know how I can update the parameters of URL(window.history) based on multi groups of check-boxes if any of group been checked? like (if only the make selected) www.mydomain/filters?make=toyota,honda or if make and model is selected www.mydomain/filters?make=toyota,honda&model=crv,cx5 $(document).ready(function() { $(“input:checkbox[name=’make’]”).change(function() { var makechecks = […]

Categories
Mastering Development

Java calling a void method in a different class to a main class?

I have a method to issue a parkingTicket in my officer class, public ParkingTicket issueParkingTicket(ParkedCar car,ParkingMeter meter){ if(isParkingTimeExpired(car,meter) == true){ ParkingTicket ticket = new ParkingTicket(officerName,officerBadgeNumber,car.getLicensePlateNumber(),calculateFine(car,meter)); ticket.displayDetails(); return ticket; } else { return null; } } I was asked to modify it in a way to have it not return anything so i made it void, […]

Categories
Development

How to replace the string in the text if the string is in a list in Python?

The dataframe has 2 columns: sentence and list. The requirement is to replace the string in df[‘sentence’] which is present in df[‘list’] with string found|present. from pandas import DataFrame df = {‘list’: [[‘Ford’,’Mercedes Benz’],[‘ford’,’hyundai’,’toyota’],[‘tesla’],[]], ‘sentence’: [‘Ford is less expensive than Mercedes Benz’ ,’toyota and hyundai mileage is good compared to ford’,’tesla is an electric car’,’toyota […]