Category "pandas"

Pandas update and add rows one dataframe with key column in another dataframe

I have 2 data frames with identical columns. Column 'key' will have unique values. Data frame 1:- A B key C 0 1 k1 2 1 2 k2 3 2 3 k3 5 Data f

Pandas dataframe read_csv on bad data

I want to read in a very large csv (cannot be opened in excel and edited easily) but somewhere around the 100,000th row, there is a row with one extra column ca

Select rows by partial string match in index

Having a series like this: ds = Series({'wikipedia':10,'wikimedia':22,'wikitravel':33,'google':40}) google 40 wikimedia 22 wikipedia 10 wikitra

How to fix IndexError: invalid index to scalar variable

This code generates error: IndexError: invalid index to scalar variable. at the line: results.append(RMSPE(np.expm1(y_train[testcv]), [y[1] for y in y_test])

Pandas: Setting no. of max rows

I have a problem viewing the following DataFrame: n = 100 foo = DataFrame(index=range(n)) foo['floats'] = np.random.randn(n) foo The problem is that it does

Way to convert dbf to csv in python?

I have a folder with a bunch of dbf files I would like to convert to csv. I have tried using a code to just change the extension from .dbf to .csv, and these f

How do I get quarterly S&P500 constituents in Python from the detailed change data?

I want to use S&P500 company information to calculate an index. However, the companies in S&P500 changes frequently, I want to know the constituents for

pandas monthly resample 15th day

I am trying to resample to monthly values but with respect to 15th day I checked the timeseries offsets documentation but there is only M month end frequenc

Parsing py2neo paths into Pandas

We are returning paths from a cypher query using py2neo. We would like to parse the result into a Pandas DataFrame. The cypher query is similar to the followin

Get the row(s) which have the max value in groups using groupby

How do I find all rows in a pandas DataFrame which have the max value for count column, after grouping by ['Sp','Mt'] columns? Example 1: the following DataFram

unhashable type 'list' error with get_dumies

I have a dataframe with data like the sample data below. I'm trying to create dummy variables for the values in the categories field using get_dummies but I'm

get previous value of pandas datetime index

I have a pandas dataframe with datetime index Date 2013-02-22 00:00:00+00:00 0.280001 2013-02-25 00:00:00+00:00 0.109999 2013-02-26 00:00:00+00:00 -0.

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:

Import pandas could not be resolved from source Pylance(reportMissingModuleSource)

I've been trying to use the packages pandas, numpy, matplotlib, seaborn in my "Visual Studio Code", but the program keeps showing me the following message: "im

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

How to read .csv with a compound header into a xarray DataArray (using pandas)

Given a dataset with the following structure: time var1 var2 var2 var1 var3 loc1 loc1 loc2 loc2 loc1 1 11 12 13 14 15 2 21

How to read .csv with a compound header into a xarray DataArray (using pandas)

Given a dataset with the following structure: time var1 var2 var2 var1 var3 loc1 loc1 loc2 loc2 loc1 1 11 12 13 14 15 2 21

formatting timedelta64 when using pandas.to_excel

I am writing to an excel file using an ExcelWriter: writer = pd.ExcelWriter(fn,datetime_format=' d hh:mm:ss') df.to_excel(writer,sheet_name='FOO') The writi

How to scale a dataframe with datetime field in it (as a index)?

I want to scale a dataframe, which raises the error as in the title (or below). My data: df.head() timestamp open high low close volume 0 2020-06-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