Category "pandas"

How can fit a keras model with a dataframe of numpy arrays?

I want to train a model with self-generated matrices (word vectors). My data have the following datatypes: print(type(X)) print(type(X[0])) print(type(X[0][0]))

Generating a Non Linear equation in Python like an excel output

I have some sample data below: Freemium: 0.5, 0.3333 , 0.1666, 0.0466, 0.0466, 0.1, 0.1666, 0.3333, 0.5 Minutes:0, 60, 120 ,180 ,240 ,300 ,360 ,420, 480 I want

Scipy linprog constraints not satisfied

I’ve defined a linear programming model using scipy linprog however the equality constraints when I calculate them manually do not satisfy the constraint.

Need pandas groupby.count() or groupby.size.unstack() to output a dataframe I can use

So I need to count the number of occurrences of a value per year, per animal. I've managed to do it but it's outputting a single column kind of dataframe rather

Entire Pandas Column Read in as NAN from read_csv()

I'm having trouble reading in my CSV file with Pandas. It's reading in a stock dataset which contains the Date and OHLCV columns, but for some reason, it's read

How to unmelt a completely melted table

I have this dataframe df which I have melted and then using pd.pivot_table I am able to get the table structure back at least looking at the rows it seems so -

How to create a comparison plot from an Excel file with many worksheets

I want to create a plot that will have in the x axis the months and for each country it will show the Orders per month. Attempting to create a function that rea

Python: Compare values of two fields with multiple strings and add all unique values to a 3rd field

I am still a Python-Rookie and are stuck with an idea. I want to compare the values of Type1 with Type2 and add all unique values to a 3rd field. My demo data:

Replacing a value in a column with a value from the same column based upon information

I am looking for a way to do Missing value imputation. There is a table of entries over a given time, with an entry per hour done on days. There is a seperate

Calculate Mean Absolute Error for each row of a Pandas dataframe

Below is a sample of pandas dataframe that I'm working with. I want to calculate mean absolute error for each row but only considering relevant columns for valu

`pandas.to_latex` - how to make column names bold

When I'm using the pandas.to_latex function to create latex table, the column names are unfortunately not bold. What can I do to make it bold?

Failing to remove all $ in strings in a dataframe

I'm trying to remove unnecessary values in the strings in my dataframe so I can make them integers and do some math logic on them. The commas, and upward arrows

Export multiple .csv files into .txt files in one go

I have multiple .csv files with different names like ATUL.csv, ISEC.csv, XYZ.csv and so on... Every file has similar data format mentioned below: datetime

How to highlight subrow from DF

I have made a function which add subrows to an initial DF : def AddSubrows(FullDF,DF): OutputDf = pd.DataFrame([]).reset_index(drop=True) for i in range

Scikit-learn pipeline: Non-finite test scores error / Inconsistent number of samples

I have a dataframe with two columns of texts and only the POS tags (of the same texts), which I want to use for language classification. I am trying to use both

Why does column + column concatenation create arrays for some Windows accounts?

When running the below Python code, I get different results depending on the user account/admin privileges that is used. The code is saved as test.py on a Windo

Select all in pandas where column equals value and all other columns are blank

I have a DataFrame containing permissions for roles of each user, e.g. function/role role1_permissions role2_permissions role3_permissions role4_permissions ca

Pandas : How to apply a function with multiple column inputs and where condition

I have a pandas dataframe. I want to generate a new variable (column) based on multiple column inputs where the year index is greater than a certain value. The

SettingWithCopyWarning Python3

I am finding the max of df2 by row, and setting the max value to new col on df1. df1['max'] = df2[df2.keys().tolist()].max(axis=1) This line is throwing a Sett

how to read a csv file edited from excel in python?

Hi I tried loading the csv file that has been edited and saved as csv comma delimited. However it's not loading right. I used the normal pd_read_csv like so. df