Category "pandas"

If value is greater than the previous replace with previous in Pandas

I am working on a data processing script that does some basic calcs from data files and sorts the data. The last piece to the puzzle is identifying if the next

How to replace column values with dictionary keys

I have a df, A B one six two seven three level five one and a dictionary my_dict={1:"one,two",2:"three,four"} I want to replace df.A with my_di

df.to_csv function prints out the content instead of writing data to a file

df.to_csv(output_file) is supposed to write the content of a DataFrame to a file. While the function is working for 99.9% of the file in my directory, there is

TENSORFLOW: UNSUPPORTABLE CALLABLE

I am trying to build the following model but am getting this error when I am finally training the model and trying to get it's accuracy. It gets stuck when I am

Converting datetime only to time in pandas

I would like to ask a question regarding converting datetime only to time. I have values 'Date Created" that include Dates and Times in one column and I would l

How to indicate leading zero differences row wise?

I have this as the ID numbers: "00456, 0000456, 567, 00567" in a dataframe called "test". I created a dataframe where it has the IDs with leading zeros in a col

Python Pandas - Find difference between two data frames

I have two data frames df1 and df2, where df2 is a subset of df1. How do I get a new data frame (df3) which is the difference between the two data frames? In o

How to open a .tsv file in Jupyter? Jupyter.Notebook tried suggestions, but it doesn't work

How can I open a .tsv file in Jupyter. The data is stored under C:/User/anna/. This is my code: import pandas as pd df=pd.read_csv('C:/User/anna/train') Bu

Pandas - Duplicate Rows and Slice String

I'm trying to create duplicate rows during a dataframe on conditions. For example, I have this Dataframe. students = [ ("a", "Ursula"), ("b", "Hayfa, Ma

Python Dataframes - Breaking out single rows with duplicate columns into multiple rows and fewer columns

I have a data frame like this: A B C Date1 Time1 Value1 Date2 Time2 Value2 abc def ghi 01-01-2000 15:00:00 100 01-01-2000 19:00:00 110 There are duplicate col

Pandas - Add a new column extracting value from arrays based on other column value

I am currently stuck trying to extract a value from a list/array depending on values of a dataframe. Imagine i have this array. This array i can manually create

Pandas - Add a new column extracting value from arrays based on other column value

I am currently stuck trying to extract a value from a list/array depending on values of a dataframe. Imagine i have this array. This array i can manually create

How to fill null values in python datatable?

Pandas library has a really good function call .fillna() which can be used to fill null values df = df.fillna(0) I am using Datatable Library for my new assign

Rolling Gradient for Pandas Dataframe column

How can I create a column in a pandas dataframe with is the gradient of another column? I want the gradient to be run over a rolling window, so only 4 data poin

KeyError: "None of [Index(['', ''], dtype='object')] are in the [columns]" when trying to select columns on a dask dataframe

I am creating a dask dataframe from a pandas dataframe using the from_pandas() function. When I try to select two columns from the dask dataframe using the squa

pandas Groupby matrix of one condition based on the other condition bin by time

I have a Dataset like below that divided to two desired group by below condition Employee No Event date Event Description Quarter Year 102 2021-10-12 First Hir

Pandas truncating display even after setting max_colwidth to -1

I am learning text mining and was working on twitter data by following code from here Although the code is for 2.xx I have converted it to 3.xx. I have only us

Key error python algorithmic trading using google collab with iex cloud api

I am following this code from a youtube video it uses iex cloud API. I have followed the video till now but I am stuck at this point enter code here # Function

Sliding Window Date Range for pandas

Pandas date_range function allows us to make Rolling Windows with a frequency. pd.date_range(start='2019-06-01', end='2019-07-01', freq='3D') # Output Datetim

Slicing a dataframe using matches to build a new dataframe with Pandas?

I am trying to get my code to take in a dataframe, find all occurrences of "START:", then iterate through each occurrence to create 'slices' (Where the first ro