multiple-columns

How do I use numpy arctan2 within polars dataframe?

How do I use numpy arctan2 within polars dataframe? Question: I am trying to use numpy arctan2 in polars dataframe. The code works outside of polars import polars as pl import numpy as np data = pl.from_dict( {‘v’: [-4.293,-2.4659,-1.8378,-0.2821,-4.5649,-3.8128,-7.4274,3.3443,3.8604,-4.2200], ‘u’: [-11.2268,6.3478,7.1681,3.4986,2.7320,-1.0695,-10.1408,11.2327,6.6623,-8.1412]}) this works v = data [‘v’].to_list() u = data [‘u’].to_list() wd = np.round(np.degrees(np.arctan2(v,u).tolist())+180,3) print(wd) …

Total answers: 3

Create df column based on other columns in df

Create df column based on other columns in df Question: Create len column based on num_type_len by matching with num on two columns. num_type_len Actual_num [8812_CHECKING_90, 7094_SAVINGS_75, 9939_CHECKING_89] 7094 [6846_CHECKING_87, 1906_CHECKING_90] 1906 Expected output:- | Report_length | Actual_num | | ————- | ———- | | 75 | 7094 | | 90 | 1906 | Asked …

Total answers: 1

Create "Yes" column according to another column value pandas dataframe

Create "Yes" column according to another column value pandas dataframe Question: Imagine I have a dataframe with employee IDs, their Contract Number, and the Company they work for. Each employee can have as many contracts as they want for the same company or even for different companies: ID Contract Number Company 10000 1 Abc 10000 …

Total answers: 2

How to define a function based on vaues of multiple columns

How to define a function based on vaues of multiple columns Question: I have a datafile as follows: Activity Hazard Condition consequence welding fire chamber high painting falling none medium I need to create a fifth column based on the values in the activity, hazard, condition, and consequence columns. The conditions are as follows if …

Total answers: 2

How to assign multiple column in one go with dictionary values?

How to assign multiple column in one go with dictionary values? Question: I have a pandas dataframe and a function that returns a dictionary. I want to assign the result of the function to multiple columns. But the problem is, the function returns a dictionary that I want to save only the values to columns. …

Total answers: 1

Convert dataframe to 5*5 grid of choice

Convert dataframe to 5*5 grid of choice Question: Following are the standard values for score and grades. Score column contains numbers within specified range. Score Grade1 Grade2 Grade3 Grade4 <260 A1 IA1 D1 ID1 260-275 A2 IA2 D2 ID2 275-280 A3 IA3 D3 ID3 280-285 A4 IA4 D4 ID4 >=285 A5 IA5 D5 ID5 Input …

Total answers: 1

Substract 2 Columns and show the current Value on a new one

Substract 2 Columns and show the current Value on a new one Question: I have this DataFrame: Names Account_1 Account_2 ID_Movement Less_1 Less_2 Peter 35 70 Movement_1 0 5 Peter 35 70 Movement_2 6 0 Peter 35 70 Movement_3 1 0 Peter 35 70 Movement_4 0 2 Jhon 55 60 Movement_5 6 0 Jhon 55 …

Total answers: 3