Category "pandas"

I am trying to merge two dataframes

I have this dataframe firm formtype Date_Filed GameStop Corp. 8-K 2021-04-01 I want to change the Date_Filed to 2021-04-01 00:00:00. I am using

pandas.query in a chain not giving expected results

I have a pandas dataframe that looks like this: df = pd.DataFrame( { "ID": [1, 2, 3, 4], "Name": ["Alpha", "Beta", "Gamma", "Delta"],

Calculations on a pandas DataFrame column conditional on another column

I notice several 'set value of new column based on value of another'-type questions, but from what I gather, I have not found that they address dividing values

Type error for a column that exists within the dataframe I am trying to call

Essentially, I am getting a key error in my jupyter notebook when trying to merge two data frames. As I understand it, a key error will only occur if said colum

DataFrame challenge: mapping ID to value in different row. Preferably with Polars

Consider this example: import polars as pl df = pl.DataFrame({ 'ID': ['0', '1', '2', '3', '4', '5','6', '7', '8', '9', '10'], 'Name' : ['A','','','','B

Select Value from largest index for each year [duplicate]

New to the Python world and I'm working through a problem where I need to pull a value for the largest index value for each year. Will provide

How to evenly spread out date data (pandas)

I'm working on a project and I'm struggling with some formats of dataframes. I have two dataframes, each containing a different number of months. I want all the

Flatten XML data as a pandas dataframe

How can I convert this XML file at this address into a pandas dataframe? I have downloaded the XML as a file and called it '058com.xml' and run the code below,

How to create a dummy only if a column has non-zero values for certain dates but zero for other dates

Let's say, I want to identify traders who only traded during bull runs but did not trade (zero values) during downturns or stable periods. Let's say we have two

Retrieve name of column from its Index in Pandas

I have a pandas dataframe and a numpy array of values of that dataframe. I have the index of a specific column and I already have the row index of an important

Python, Pandas and intersection - not PIVOT

This isn't a straightforward pivot question. I don't want to create new named columns (or numbered ones). What I am looking for is to find a way to search for

how to replace the particular column value using python

Input Data Frame output data frame in output, some particular column should be replace and other value of other column should be repeated

How to save each output by iteration of a loop in separate csv files

I have a file in which i calculate a startdate and enddate, these dates change by iteration each time between a range of dates. the code works fine but i don't

Transform a dataset from wide to long pandas

I have a little problem with the transformation from wide to long on a dataset. I tried with melt but I didn't get a good result. I hope that someone could help

Pandas: how to filter out rows containing a string pattern within a list in a column?

I have a data frame that looks similar to the following: df = pd.DataFrame({ 'employee_id' : [123, 456, 789], 'country_code' : ['US', 'CAN', 'MEX'],

populating dataframe with youtube api

list2=['PewDiePie', 'jacksepticeye', 'iDubbbzTV', 'Markiplier','MarkiplierGAME', 'EminemMusic','EdSheeran', 'TaylorSwift', 'CNN', 'FoxNews', 'CBCNews', 'ABCNew

Remove rows in dataframe based on value counts of unique identifier

Identifier Value_1 Value_2 Value_3 123 20. 30. 1 123. 12. 14. 1 123. 18. 12. 1 124. 12. 10. 6 124.

Python Dash - add submit button at the end of multiple inputs. Also format output table nicely

Want to create a dash board, with two or more inputs, a submit button at the end of inputs that outputs a table. I am having trouble creating properly spaced in

How to add new column to pandas group? Pandas forgets the column

I have a pandas dataframe indexed by createdAt grouped by pid (participant identifiers). The created at column are unix timestamps. Now I would like to add a ne

Creating a summary statistics table in python

I am trying to recreate the 'SummarySE()' function from R in python but I am having trouble getting it to work. The function creates a summary stats table from