Category "dataframe"

pandas diff() giving 0 value for first difference, I want the actual value instead

I have df: Hour Energy Wh 1 4 2 6 3 9 4 15 I would like to add a column that shows the per hour differenc

Combining Python variables into SQL queries

I am pulling data from an online database using SQL/postgresql queries and converting it into a Python dataframe using Pandas. I want to be able to change the d

Joining on datetime64[ns, UTC] fails using pandas.join

I'm trying to join two pandas.DataFrames on a datetime64[ns, UTC] field and it's failing with a ValueError (described below) that is not intuitive to me. Consid

Chunking DataFrame by gaps in datetime index

First of all, my apologies if the title was too ambiguous. I have a pd.DataFrame with datetime64 as a dtype of index. These indices, however, are not equally

Python Pandas add Filename Column CSV

My python code works correctly in the below example. My code combines a directory of CSV files and matches the headers. However, I want to take it a step furthe

Pandas - find specific value in entire dataframe

I have a dataframe and I want to search all columns for values that is text 'Apple'. I know how to do it with one column, but how can I apply this to ALL column

How to extract values from key value map?

I have a column of type map, where the key and value changes. I am trying to extract the value and create a new column. Input: ----------------+ |symbols

Dataframe Column name not defined PowerBI Python Integration

i wrote code to visualize matplotlib bar chart using the python Jupiter notebook. But now I wanted to integrate that code with powerBI. That dataset includes 3

Insert a row to pandas dataframe

I have a dataframe: s1 = pd.Series([5, 6, 7]) s2 = pd.Series([7, 8, 9]) df = pd.DataFrame([list(s1), list(s2)], columns = ["A", "B", "C"]) A B C 0 5

python: how to melt dataframe retaining specific order / custom sorting

I have a dataframe df Cat B_1 A_2 C_3 A 1 2 3 B 4 5 6 C 7 8 9 which I want to convert into a dataframe so that the rows in column

kronecker product pandas dataframes

I have two dataframes A B 0 1 2 1 1 2 2 1 2 and C D 0 1 4 1 2 5 2 3 6 I need the mean of the cross products (AC, AD, BC, BD).

Python Pandas Dataframe Datetime Range

Here is my code block: import pandas as pd import datetime as dt first_day = dt.date(todays_year, todays_month, 1) print(first_day) >2021-02-01 print(type(

Can't manipulate dataframe in pandas

Don't understand why I can't do even the most simple data manipulation with this data i've scraped. I've tried all sorts of methjods to manipulate the data but

Adding a fixed value to a DF

I have generated a DF from the below code: url='https://www.rootsandrain.com/event4493/2017-aug-26-uci-world-cup-dh-7-val-di-sole/results/' response = requests.

convert column to table header in pandas dataframe

I have this dataframe: identifier_1 measure Value identifier_2 abc height 12 oii abc weig

Sum a column values based on a condition using spark scala

I have a dataframe like this: JoiKey period Age Amount Jk1 2022-02 2 200 Jk1 2022-02 3 450 Jk2 2022-03 5 500 Jk3 2022-03 0 200 Jk2 2022-02 8 300 Jk3 2022-03 9

Single column to multiple columns with columns as heading and fill with binary values

Given column in the csv file labels ['N'] ['C'] ['D'] ['A'] ['D','C'] ['H'] ['D','G'] ['M'] ['O'] I want the labels a

Get the rate of change by finding the change in price

UPDATE: I'm getting a strange result in the outcome. Occasionally, the earliest date of the result show after 2 or 3 etc times for example Item Kg Date_1 Price

How to create a new table in a MySQL DB from a pandas dataframe

I recently transitioned from using SQLite for most of my data storage and management needs to MySQL. I think I've finally gotten the correct libraries installed

Check for existence of multiple columns

Is there a more sophisticated way to check if a dataframe df contains 2 columns named Column 1 and Column 2: if numpy.all(map(lambda c: c in df.columns, ['Colum