Category "dataframe"

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

Convert a Column to Column Header

I have a list of dict containing x and y. I want to make x the index and y the column headers. How can I do it? import pandas pt1 = {"x": 0, "y": 1, "val": 3,}

Split cell into multiple rows in pandas dataframe

I have a dataframe contains orders data, each order has multiple packages stored as comma separated string [package & package_code] columns I want to split

Remove rows that contain False in a column of pandas dataframe

I assume this is an easy fix and I'm not sure what I'm missing. I have a data frame as such: index c1 c2 c3 2015-03-07 01:2

python dataframe pandas drop column using int

I understand that to drop a column you use df.drop('column name', axis=1). Is there a way to drop a column using a numerical index instead of the column name?

compare multiple columns of pandas dataframe with one column

I have a dataframe: df- A B C D E 0 V 10 5 18 20 1 W 9 18 11 13 2 X 8 7 12 5 3 Y 7 9 7 8 4 Z 6 5 3 90

Major rearrangement of pandas DataFrame containing nested lists and dictionaries ( CFBD (College Football Database))

The College Football Database (cfbd) contains all team ranks for each week of every college football season going back to 1937.I am trying to set up data from t

compare multiple columns of pandas dataframe with one column

I have a dataframe: df- A B C D E 0 V 10 5 18 20 1 W 9 18 11 13 2 X 8 7 12 5 3 Y 7 9 7 8 4 Z 6 5 3 90

Get DataFrame with the number of rows for each time interval

Given the following DataFrame of pandas in Python: | ID | date | |--------------|------------------------------------

Splitting dataframe into multiple dataframes

I have a very large dataframe (around 1 million rows) with data from an experiment (60 respondents). I would like to split the dataframe into 60 dataframes (a d