Category "pandas"

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

How to convert a nested dict, to a pandas dataframe

I'm trying to convert a dataframe that has inside other dataframe like: { 'id': 3241234, 'data': { 'name':'carol', 'lastname': 'netfli

How to count the same rows between multiple CSV files in Pandas?

I merged 3 different CSV(D1,D2,D3) Netflow datasets and created one big dataset(df), and applied KMeans clustering to this dataset. To merge them I did not use

Efficient way to unnest (explode) multiple list columns in a pandas DataFrame

I am reading multiple JSON objects into one DataFrame. The problem is that some of the columns are lists. Also, the data is very big and because of that I canno

converting a SAS Macro to python with Pandas?

I'm converting a program of SAS code into a python equivalent. One section that i'm struggling with is how to convert a macro program in SAS when the variables

how to append data frame to existed formulated excel file

if u have a formulated excel file and now wants to append data frame by python then how.. I used this code but did not get output mypath="C:\\Users\\egoyrat\\

Pandas wide to long bringing empty DataFrame

I was working in a pretty simple task: applying wide_to_long to a DataFrame, but every time I ran it, I got an empty DataFrame. I was almost sure I was doing it

Get CSV from google drive and then load to pandas

My Goal is to read a .csv file from google drive and load it to a dataframe. I tried some answers here but the thing is, the file is not public and needs authen

ValueError: Incompatible indexer with Series while adding date to Date to Data Frame

I am new to python and I can't figure out why I get this error: ValueError: Incompatible indexer with Series. I am trying to add a date to my data frame. The da