dataframe

Move specific column information to a new row under the current row

Move specific column information to a new row under the current row Question: Consider this df: data = { ‘Name Type’: ["Primary", "Primary", "Primary"], ‘Full Name’: ["John Snow", "Daenerys Targaryen", "Brienne Tarth"], ‘AKA’: ["Aegon Targaryen", None, None], ‘LQAKA’: ["The Bastard of Winterfell", "Mother of Dragons", None], ‘Other’: ["Info", "Info", "Info"]} df = pd.DataFrame(data) I need …

Total answers: 1

Split and match names in a df with another df and return the matching firms

Split and match names in a df with another df and return the matching firms Question: Please help me with this particular scenario. I’ve been able to partially do this but the final dataframe does not look correct for all the rows. I have two Dataframes: df1: Name A/B/C D/E F/G df2: First Name Last …

Total answers: 3

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