dataframe

How to split an array using its minimum entry

How to split an array using its minimum entry Question: I am trying to split a dataset into two separate ones by finding its minimum point in the first column. I have used idxmin to firstly identify the location of the minimum entry and secondly iloc to slice the array from 0 to the minimum …

Total answers: 1

How to change columns values(list) using another data frame in Python

How to change columns values(list) using another data frame in Python Question: I have two data frame, I need to change column values of first data frame that are in list, using second data frame. First Data frame df1 = pd.DataFrame({‘title’:[‘The Godfather’,’Fight Club’,’The Empire’], genre_ids’:[[18, 80],[18],[12, 28, 878]]}) title genre_ids 0 The Godfather [18, 80] …

Total answers: 2

How to convert timedelta in data frame to datetime

How to convert timedelta in data frame to datetime Question: I have couple columns in df with avg time, example "0 days 00:00:21". I want convert all columns to datetime.time format "hh:mm:ss" without "0 days". How can I do this? my df Asked By: Grzegorz Z || Source Answers: not sure how you data is …

Total answers: 2

Cannot Convert Local CSV to dataframe in Pandas on Spyder

Cannot Convert Local CSV to dataframe in Pandas on Spyder Question: Hello I am learning Python using Spyder (Python 3.8.10 64-bit | Qt 5.15.2 | PyQt5 5.15.10 | Windows 10 (AMD64). I am unable to convert a local copy of a csv into a dataframe using pandas # import pandas module import pandas as pd …

Total answers: 1

Fitting Variable Number of Lorentzian Peaks to a glob of data in text files

Fitting Variable Number of Lorentzian Peaks to a glob of data in text files Question: So I’ve gotten the code to work, but it’s extremely slow and doesn’t give the proper full width at half maxima. Is there something I can do to get the FWHM values and speed up the processing without losing post-processing …

Total answers: 1

Pandas to_excel formatting float values

Pandas to_excel formatting float values Question: I’m exporting a dataframe to an excel file using to_excel from pandas but I need that all the number values (float64) to be formatted (without specifing each columns because that will be variable) as a string (BRL currency) when exported. import pandas as pd df = pd.DataFrame({‘Numero’: {0: ‘044121’, …

Total answers: 3

Conditional merging with pandas

Conditional merging with pandas Question: I have a pandas dataframe as below which details additional calls into an area: CommsDate Area Day0 Incremental Day1 Incremental Day2 Incremental 01/01/24 Sales 43 36 29 01/01/24 Service 85 74 66 02/01/24 Sales 56 42 31 02/01/24 Service 73 62 49 03/01/24 Sales 48 32 24 03/01/24 Service 67 …

Total answers: 1

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