dataframe

subset dataframe to show on GUI Tkinter

社会主义新天地 提交于 2021-02-11 14:31:14
问题 I have dropdown option in tkinter which select the option of dropdown by groupby the col1 by dataframe pandas , Now I am able to see the subset of dataframe by clicking ok button in my terminal , I want to see the subset dataframe after selecting into dropdown in my GUI , Please let me know how to see the subset dataframe a/c to dropdown option into my GUI . import tkinter as tk import pandas as pd # --- functions --- def on_click(): val = selected.get() if val == 'all': print(df) else: df2 =

What's the most efficient way to convert a time-series data into a cross-sectional one?

本小妞迷上赌 提交于 2021-02-11 14:30:25
问题 Here's the thing, I have the dataset below where date is the index: date value 2020-01-01 100 2020-02-01 140 2020-03-01 156 2020-04-01 161 2020-05-01 170 . . . And I want to transform it in this other dataset: value_t0 value_t1 value_t2 value_t3 value_t4 ... 100 NaN NaN NaN NaN ... 140 100 NaN NaN NaN ... 156 140 100 NaN NaN ... 161 156 140 100 NaN ... 170 161 156 140 100 ... First I thought about using pandas.pivot_table to do something, but that would just provide a different layout grouped

How to indicate two highest observations in group (with two conditions)?

南笙酒味 提交于 2021-02-11 14:25:24
问题 Per request from Ronak. This is my data set: Month Week Y Name Color January 2 1.2 Joe Red January 2 3.3 Eric Red January 2 4.5 Mike Blue January 2 1.7 Brian Blue January 2 2.9 Pete Red January 2 6.8 Dave Red January 3 4.6 Joe Red January 3 5.1 Eric Blue January 3 2.1 Mike Blue January 3 6.9 Pete Red January 3 6.8 Dave Red ... I would like to create a new column ('Highest') which identifies the individuals with the two highest Y values in a given week (identifying them with A and B so it will

SUMIFS in python jupyter

早过忘川 提交于 2021-02-11 14:25:16
问题 I have this dataframe. This is a transaction of exchange goods. So basically the client can switch into those goods which have the same quality or lower. So for Client 1 on 16/08/2019, 360 B grade goods switch into 180 B and 180 A goods. This needs to be flagged. I can do this in excel, however, the file is too big and it crashes. In/Out Client Quality Date GoodsAmount In 1 A 16/08/2019 180 In 1 B 16/08/2019 180 Out 1 B 16/08/2019 360 In 2 C 14/08/2019 130 Out 2 B 14/08/2019 45 Out 2 C 14/08

Converting XML to Pandas

旧时模样 提交于 2021-02-11 14:21:17
问题 Is there a way to convert an XML file (financial statements from IB API) to Pandas without knowing the exact column headers? The rows should reflect the different dates (there are 4 or more datapoints per column). Would also be great to get balance sheet, income statement and cash flow statement separately. I have tried to use beautiful soup but am getting frustrated because it seems like I need to look for each column header specifically and I don't know how to get the data for each date. Im

Calculate nearest distance to certain points in python

微笑、不失礼 提交于 2021-02-11 14:16:19
问题 I have a dataset as shown below, each sample has x and y values and the corresponding result Sr. X Y Resut 1 2 12 Positive 2 4 3 positive .... Visualization Grid size is 12 * 8 How I can calculate the nearest distance for each sample from red points (positive ones)? Red = Positive, Blue = Negative Sr. X Y Result Nearest-distance-red 1 2 23 Positive ? 2 4 3 Negative ? .... dataset 回答1: Its a lot easier when there is sample data, make sure to include that next time. I generate random data

multiple merge operations on two dataframes using pandas

倖福魔咒の 提交于 2021-02-11 13:59:43
问题 I have two dataframes where multiple operations are to be implemented, for example: old_DF id col1 col2 col3 ------------------------- 1 aaa 2 bbb 123 new_DF id col1 col2 col3 ------------------------- 1 xxx 999 2 xxx kkk The following operations need to be performed on these dataframes: Merging the two dataframes Replacing only the blanks (NAs) cells in the old_DF with corresponding values from new_DF Cells from both the dataframes where the values are contradicting should be reported in a

how do I perform a vlookup equivalent operation on my dataframe with some additional conditions

扶醉桌前 提交于 2021-02-11 13:58:39
问题 HI I am trying to run lookup equivalent function on python but having tried merge and join I haven't hit the nail yet. so my first df is this list = ['Computer', 'AA', 'Monitor', 'BB', 'Printer', 'BB', 'Desk', 'AA', 'Printer', 'DD', 'Desk', 'BB'] list2 = [1500, 232, 300, 2323, 150, 2323, 250, 2323, 23, 34, 45, 56] df = pd.DataFrame(list,columns=['product']) df['number'] = list2 This is how the df would look product number 0 Computer 1500 1 AA 232 2 Monitor 300 3 BB 2323 4 Printer 150 5 BB

multiple merge operations on two dataframes using pandas

自作多情 提交于 2021-02-11 13:58:25
问题 I have two dataframes where multiple operations are to be implemented, for example: old_DF id col1 col2 col3 ------------------------- 1 aaa 2 bbb 123 new_DF id col1 col2 col3 ------------------------- 1 xxx 999 2 xxx kkk The following operations need to be performed on these dataframes: Merging the two dataframes Replacing only the blanks (NAs) cells in the old_DF with corresponding values from new_DF Cells from both the dataframes where the values are contradicting should be reported in a

Failing to create the data frame and populating its data into the csv file properly

杀马特。学长 韩版系。学妹 提交于 2021-02-11 13:56:10
问题 I'm looking to scrape this link, with just two simple pieces of information, but I don't know why I have this result and it can't give me all the data I search for: particulier_allinfo particulier_tel 0 ABEL KEVIN10 RUE VIRGILE67200 Strasbourg This is the code, thanks for your help : import bs4 as bs import urllib import urllib.request import requests from bs4 import BeautifulSoup import pandas from pandas import DataFrame import csv with open('test_bs_118000.csv', mode='w') as csv_file: