Category "dataframe"

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

df.isna().sum() is not working on titanic dataset

I tried titanic model on kaggle. And it is weird that isna().sum() outputs wrong information. import os import pandas as pd import numpy as np import statsmode

How to name the column when using value_count function in pandas?

I was counting the no of occurrence of angle and dist by the code below: g = new_df.value_counts(subset=['Current_Angle','Current_dist'] ,sort = False) the out

Removing [' and '] from CSV

I have several GB of CSV files where values in one of the columns look like this: Which is a consequence of this: urls.append(re.findall(r'http\S+', hashtags_r

Converting pandas.DataFrame to bytes

I need convert the data stored in a pandas.DataFrame into a byte string where each column can have a separate data type (integer or floating point). Here is a

how to check if a None is not passed as an argument where a pandas dataframe is expected

I have a function which looks like below. def some_func(df:pd.Dataframe=pd.Dataframe()): if not df or df.empty: //some dataframe operations I want to ens

How to create a dictionary of two pandas DataFrame columns

What is the most efficient way to organise the following pandas Dataframe: data = Position Letter 1 a 2 b 3 c 4 d 5

Python pandas: fill a dataframe row by row

The simple task of adding a row to a pandas.DataFrame object seems to be hard to accomplish. There are 3 stackoverflow questions relating to this, none of which

Add a duplicate row and change the value of the duplicated row based on some other value in Pandas

I want to merge 2 columns of the same dataframe, and add a duplicate row using the same values as it has in the other columns. consider the following dataframe:

How to switch columns rows in a pandas dataframe

I have the following dataframe: 0 1 0 enrichment_site value 1 last_updated value 2

Pandas DataFrame: replace all values in a column, based on condition

I have a simple DataFrame like the following: I want to select all values from the 'First Season' column and replace those that are over 1990 by 1. In this e

Problem using IMF data API for a large number of countries

I am trying to download national account data from the API of the International Financial Statistics from the International Monetary Fund. I don't have any trou