Category "pandas"

How to convert DataFrame.append() to pandas.concat()?

In pandas 1.4.0: append() was deprecated, and the docs say to use concat() instead. FutureWarning: The frame.append method is deprecated and will be removed fr

Pivot dataframe with duplicate index by aggregating per group

I am facing the following dataframe. Date Security Field Value 0 2022-05-03 08:00:12.394000 CFI2Z2 VALUE 83.3 1 2022-05-03 08:00:12.394000 CFI2Z2 VOLUME 1 2 2

How to merge every two columns, with pandas, substituting only if the left column value is nan or 0 [duplicate]

I have 2n columns and each pair looks like this: 1 0 2 0 45 1 44 10 43 22 0 55 0 46 0 75 I want to turn each pair of columns int

AttributeError: 'TimedeltaProperties' object has no attribute 'minute'

I have a dataframe that looks like this df [output]: date time 2020-02-28 00:30:45 2020-02-28 00:30:45 2020-03-09 00:21:06 2020-03-09 00:21:06 2020-

efficient way of computing a list with mean of values in another list

I need to compute a list with the mean values of another list. To be more precise, the input list have this form: input_list = ['1.538075/42.507325', '1.53796

Convert a Pandas DataFrame into a single row DataFrame

I've seen similar questions but mine is more direct and abstract. I have a dataframe with "n" rows, being "n" a small number.We can assume the index is just th

Add a new logic in pyhton

Want to add logic that calculates and outputs truckloads able to be built each day. Still want this broken out by ship-to party (so 1 ship-to party per shipment

How to add a vertical scrollbar in html output from jupyter notebook with nbconvert?

I am automatizing some reports with jupyter and exporting it to html. I have some large tables, and I want to add a scrollbar to rigthside of table. A similar q

Auto adjust column width for multisheet Excel

I'm trying to auto adjust the column width for multi-sheet excel file and I've stumbled upon this result: Is there a way to auto-adjust Excel column widths with

Adding correlation result back to pandas dataframe

I am wondering how to add the corr() result back to a panda dataframe as the current output is a bit nested. I just want to have one column in the original data

How to get PRAW (the Python Reddit API Wrapper) to read submission ID?

Goal: I have collected hundreds of reddit posts' details in Excel sheets. Now, I want to collect comments on these Reddit posts using PRAW. Method: At first, I

data time Format recognition in exported excel with xlsxwriter

I didn't find a solution for this: From a dataframe I generate an excel and some columns need to be in format hh:mm:ss (with no limit to 24h, for example a valu

Repeated values in prediction with sequential model

The problem I got is with the result, I get the same value in the 'future' field in all the rows as follows. open high low close

Place the first value of Column B in Column C if Column A has same names in python pandas with loop [duplicate]

I have the following data set in python, Input I want to bring the first value of Column B that belongs to column Column A for a unique A val

Which Java class is compatible with python Pandas DataFrame when using DJL(Deep Java Library)?

I'm trying to import Python Tensorflow custom model to spring-boot using DJL Tensorflow, and the model gets Pandas DataFrame as both input and output. I'm wonde

Pandas find consecutive ones, column wise

I am having an output data frame like the one below and I wanted to format the output so that I can use it for the further pipeline. Few pointers about the data

Querying deeply nested and complex JSON data with multiple levels

I am struggling to break down the method required to extract data from deeply nested complex JSON data. I have the following code to obtain the JSON. import req

Linearregression of two dataframes

I have two dataframes: df = pd.DataFrame([{'A': -4, 'B': -3, 'C': -2, 'D': -1, 'E': 2, 'F': 4, 'G': 8, 'H': 6, 'I': -2}]) df2 looks like this (just a cutout; i

Can I use itertools.count to add values in a column, resetting at a certain point?

I'm trying to create a list of timestamps from a column in a dataframe, that resets after a certain time to zero. So, if the limit was 4, I want the count to ad

panda df not showing all rows after loading from MS SQL

I'm using Pandas with latest sqlalchemy (1.4.36) to query a MS SQL DB, using the following Python 3.10.3 [Win] snippet: import pandas as pd