dataframe

TKinter – Column width = 0 leaves yellow pixels

TKinter – Column width = 0 leaves yellow pixels Question: I am trying to only show certain columns when pressing one of the buttons on the right side, for that reason I implemented to hide the other columns by reducing their column width to 0. While this works for hiding the columns, it leaves yellow …

Total answers: 1

apply different function on each row

apply different function on each row Question: I have a dataframe with 2 columns field and value(number of rows maximum 10). I need to perform some checks depending on the field(ie need to apply different function on each row) and store its result in status column. Below is sample: data = { ‘field’: [‘a’, ‘b’], …

Total answers: 3

Interweave groups in Pandas

Interweave groups in Pandas Question: I have a DataFrame that I want "intereaved" row-wise by groups. For example, this DataFrame: Group Score A 10 A 9 A 8 B 7 B 6 B 5 The desired result would be grabbing the first of A, and the first of B, then the second of A, then …

Total answers: 2

Merge multiple (2+) dataframes in Pandas with a proper column name

Merge multiple (2+) dataframes in Pandas with a proper column name Question: everyone. I have the following list of dataframes: df_eurusd = DownloadData(‘EUR/USD’,start_date,end_date,timeframe).GetData() df_usdjpy = DownloadData(‘USD/JPY’,start_date,end_date,timeframe).GetData() df_gbpusd = DownloadData(‘GBP/USD’,start_date,end_date,timeframe).GetData() df_usdcad = DownloadData(‘USD/CAD’,start_date,end_date,timeframe).GetData() df_usdsek = DownloadData(‘USD/SEK’,start_date,end_date,timeframe).GetData() df_usdchf = DownloadData(‘USD/CHF’,start_date,end_date,timeframe).GetData() tickers = { ‘EUR/USD’ : df_eurusd, ‘USD/JPY’ : df_usdjpy, ‘GBP/USD’ : df_gbpusd, ‘USD/CAD’ : df_usdcad, ‘USD/SEK’ : …

Total answers: 2

How calculate a value using a previous values in pandas dataframe

How calculate a value using a previous values in pandas dataframe Question: I am trying to calculate a value in a pandas dataframe using the previous value. Given the values below: year sex age pxt lxt 2000 m 0 m x 2000 m 1 n y 2000 m 2 o z x = 1 (by …

Total answers: 1

Python: Extract different columns and assign to a new dataframe

Python: Extract different columns and assign to a new dataframe Question: I have this df: A B C D 1 2 3 4 I want to extract columns 0:1 and 3rd one But first thought would be: X = DS.iloc[:, 0:1:3].values But, this approach does not work Asked By: Another.Chemist || Source Answers: If really …

Total answers: 1

Is .diff(period=-10) working on pandas series?

Is .diff(period=-10) working on pandas series? Question: I have a dataframe like so: import pandas as pd import numpy as np date_rng = pd.date_range(start="2023-11-18", periods=3, freq="10S") values = [4, 2, 3] df = pd.DataFrame(data={"values": values}, index=date_rng) df["dt"] = df.index.to_series().diff().dt.seconds df["dt"] = df.index.to_series().diff(periods=2).dt.seconds df["dt_neg"] = df.index.to_series().diff(periods=-1).dt.seconds print(df) gives values dt dt_neg 2023-11-18 00:00:00 4 NaN 86390.0 …

Total answers: 1

Finding the longest streak of numbers, sum the values of that group and create an new dataframe

Finding the longest streak of numbers, sum the values of that group and create an new dataframe Question: This is an extension to this post. My dataframe is: import pandas as pd df = pd.DataFrame( { ‘a’: [ ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘a’, ‘b’, ‘b’, ‘b’, ‘b’, ‘b’, …

Total answers: 2

Searching for values in large dataframe with unnamed columns

Searching for values in large dataframe with unnamed columns Question: I have a dataframe with ~300 columns in the following format: | Column1 | Column2 | Column3 | Column5 | ————| ————– |———–|———- | Color=Blue | Location=USA | Name=Steve| N/A | Location=USA| ID=123 | Name=Randy| Color=Purple | ID=987 | Name=Gary | Color=Red | Location=Italy What …

Total answers: 3