sorting

Get last actual data

Get last actual data Question: There is a table rule_chains: ID payroll_type_id stuff_department_id start_date 1 1 89 2023-03-01 2 2 89 2023-03-01 3 1 89 2023-04-01 My problem is to get the actual entity for today. For example today is 2023-03-01 and I need to get this two entity with id = 1 and id …

Total answers: 1

Pandas want to change column data into serial number

Pandas want to change column data into serial number Question: I want to change the "Dut" column into a serial number following the number of each "ITEM" There are lots of "ITEM"s. So I want to get the number of each item. as following question Input data: data = {‘ITEM’: [‘a’, ‘a’, ‘a’, ‘a’, ‘a’, …

Total answers: 2

How to alphabetically sort values in a pandas column that is a list

How to alphabetically sort values in a pandas column that is a list Question: I had a question about sorting values in a list in a dataframe. I have sales order data with about 3000 rows. A sales order can contain one or multiple inventory items. I reshaped my data and was able to create …

Total answers: 1

Sort list by dictionary in Python

Sort list by dictionary in Python Question: I want to sort a list by a dictionary, as shown below: The list: L = [‘Jack’, ‘King’, ‘9’, ‘King’, ’10’] The dictionary: D = {0:’Ace’, 1:’King’, 2:’Queen’, 3:’Jack’, 4:’10’, 5:’9′} I want to sort L based on keys of dictionary D, such that the output would be: …

Total answers: 3

issue Letter Grades on python

issue Letter Grades on python Question: Hi all I’m having an issue with my python code. Im new to python im study at tafe and this is one of my task for introduction to python The task is to make a simple code that grades the letters from the total and in oreder for example …

Total answers: 1

Sorting CSV with IP address column in pandas

Sorting CSV with IP address column in pandas Question: I have a CSV file with a column of IP addresses, MAC addresses and some other data. I want to sort all of the data by the IP addresses in ascending order Input: | IP Address | MAC Address | ID | | — | — …

Total answers: 1

Implement sorting by multiple attributes

Implement order definition by multiple attributes Question: I’d like to know how to efficiently sort by object’s multiple attributes. For instance, given class A: def __init__(self, a, b): self.a = a self.b = b def __lt__(self, other): if self.a == other.a: return self.b < other.b return self.a < other.a def __str__(self): return f'{self.__class__.__name__}({self.a}, {self.b})’ A1 …

Total answers: 3

How to give rank on datetime column group by another column with userid in it

How to give rank on datetime column group by another column with userid in it Question: My columns are ID, User_created_date and Customer city while user_created_date is in 2023-01-01 00:01:05+05:30 format now I wanted to know when did the first user was created based on each city and give rank to them based on city …

Total answers: 1

Sort Columns by assigned column

Sort Columns by assigned column Question: I have a following code: import bs4 as bs import requests import yfinance as yf import datetime import pandas as pd import time starttimer = time.time() resp = requests.get(‘http://en.wikipedia.org/wiki/List_of_S%26P_500_companies’) soup = bs.BeautifulSoup(resp.text, ‘lxml’) table = soup.find(‘table’, {‘class’: ‘wikitable sortable’}) tickers = [] for row in table.findAll(‘tr’)[1:]: ticker = row.findAll(‘td’)[0].text …

Total answers: 2