Category "pandas"

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

Categorical column after melt in pandas

Is it possible to end up with a categorical variable column after a melt operation in pandas? If I set up the data like this: import pandas as pd import numpy a

Any optimize way to iterate excel and provide data into pd.read_sql() as a string one by one

#here I have to apply the loop which can provide me the queries from excel for respective reports: df1 = pd.read_sql(SQLqueryB2, con=con1) df2 = pd.rea

Pandas resample by integration over time with non equidistant data

I have a DataFrame with a Datetimeindex with non equidistant timestamps. I want to get the mean for each hour. But by using resample.mean(), the time distance b

Pandas Pivot table - How compute the following default ratio?

I am able to compute the default rate in number (e.g, the percentage of customers falled into default), with the code below, getting the following output: impor

Add months to a date in Pandas

I'm trying to figure out how to add 3 months to a date in a Pandas dataframe, while keeping it in the date format, so I can use it to lookup a range. This is w

Pandas dataframe divide features to group of high correlation

I have a dataframe with over 280 features. I ran correlation map to detect groups of features that are highly correlated: Now, I want to divide the features to

Adding a new column in pandas dataframe from another dataframe with differing indices

This is my original dataframe. This is my second dataframe containing one column. I want to add the column of second dataframe to the original dataframe at th

Filter data-frame for rows dates outside a date range

I have a data-frame df where the head looks like: identifier department organisation status change date 1 14 Finance

How to colour code points using Bokeh with gmap

I currently have a gmap displaying gps points, however, I was hoping there was a way to colour code my GPS points based on which month they were recorded ? I ha

Is there any way we can load BigTable data into BigQuery?

I want to load BigTable data into BigQuery with direct way. Till now I am loading BigTable data into CSV file using Python and then loading csv file into BigQue

How to download a file in PyCharm instead of !wget in Colab? [duplicate]

When I try some codes in pandas, the bash code wget is used in colab as the following: import pandas as pd !wget abc.com/sales.csv If I want

How to negate a regex for pandas replace

In pandas I can search and replace all fields that contain the word fish, for example, using df.replace(r'.*fish.*', 'foo', regex = True). But how do I sear