I have a function that has two arguments that are both lists as shown below def myfunc(arg1, arg2): return arg1*arg2 arg1 = [1,2,3,4] arg2 = [10,9,8] I want to return a list of each possible PERMUTATION of the two arguments So the result should be something like [10,9,8,20,18,16…….] I believe this isn’t possible with maps ..
Category : dataframe
I have dataframe that looks like this: State State_theft_sum Model_1 Model_year_1 Alabama 2154 Chevrolet Pickup (Full Size) 2005.0 Alaska 547 Chevrolet Pickup (Full Size) 2003.0 Arizona 5270 Honda Accord 1997.0 DF goes on and on, so changing values separately isn’t the way. I though i might be able to replace them using result of loop ..
I created code to drop some rows according to certain condition : df3 = df_clean[(df_clean[‘group’] == ‘treatment’) & (df_clean[‘landing_page’] != ‘new_page’)].index df2 = df_clean.drop(df3 , inplace=True) df2.head() but I got this error: AttributeError: ‘NoneType’ object has no attribute ‘head’ Source: Python..
I have two different dataframes, both containing a common element (identifier). I want to copy data from df1 for each identifier in df2 (each identifier can repeat maximum 5 times in df1) df1 —data vertically id_column value1 identifier1 some data1 identifier1 some data2 identifier1 some data3 identifier2 some data2 identifier2 some data1 identifier3 some data3 ..
If I have a DataFrame with numeric values in it, how do I determine which column contains the max value? EEM_X EFA_X QQQ_X SPY_X 126 0.1898 0.1490 0.1025 0.0965 127 0.1911 0.1476 0.0678 0.0793 128 0.1986 0.1590 0.0750 0.0893 129 0.2180 0.1703 0.0783 0.0924 I want to add a new column [‘MAX’] that contains the ..
I’m trying to get the RSI of a stock using TA-Lib in python and it keeps giving me wrong numbers. import talib import pandas as pd from td.client import TDClient ticker = ‘GOOG’ data = TDSession.get_price_history( symbol = ticker, period_type = ‘month’, frequency_type = ‘daily’, frequency = 1, period = 1, ) df = pd.DataFrame(data[‘candles’]) ..
I have a dataframe using Pandas with transaction data, it looks something like this. "Transactions", "State in transaction" "Company name, Florida", "N/A" "Company name, California", "N/A" "Company name, Mississipi", "N/A" "Company name", "N/A" . . . . . . And so on… I also have a data frame with states for both US and Canada. ..
I am using if condition in python to perform a calculation but I am getting The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). error Can someone please help me in understanding how to perform actions on a dataframe based on if condition on other columns? if (simulated_hour[‘Weeknnd’] == ..
Hi I have a list of dataframes that I want calculate certain columns value length and create a new columns for the calculated values. columns = [‘name’, ‘address’, ’email’] newcolumns = [‘name_length’, ‘address_length’, ’email_length’] def length(start, i, j): while i < len(columns): newcol = newcolumns[i] col = columns[j] df_list[start][newcol] = df_list[start][col].str.len() i += 1 j ..
I have been struggling to convert a text file to a pandas Dataframe, so I can subsequently do calculations on the values and plot the coordinates. The text file has the following format with a long header and then many rows. I put an example of part of the header and one row below. I ..
Recent Comments