Category "pandas"

How to create variables based on column names in dataframe?

I wanted to create variables in python based on the column names of my dataframe. Not sure if this is possible as I am quite new to Python. Lets say my df looks

How to create variables based on column names in dataframe?

I wanted to create variables in python based on the column names of my dataframe. Not sure if this is possible as I am quite new to Python. Lets say my df looks

AttributeError: Can't get attribute '_unpickle_block'

While using: with open("data_file.pickle", "rb") as pfile: raw_data = pickle.load(pfile) I get the error: AttributeError: Can't get attribute '_unpickle

RangeIndex object is not callable

I am reading values from text file and and trying to find index of sub strings like below df=pd.read_csv('break_sent.txt', index_col=False,encoding='utf-8',del

Python: pandas merge multiple dataframes

I have diferent dataframes and need to merge them together based on the date column. If I only had two dataframes, I could use df1.merge(df2, on='date'), to do

how to remove milliseconds or decimals in a specific dataframe column

I have 2 columns containing date and time(hr,min,seconds:milliseconds) How do I remove the milliseconds from only one of the column? Name MinTime

Stratified Sampling in Pandas

I've looked at the Sklearn stratified sampling docs as well as the pandas docs and also Stratified samples from Pandas and sklearn stratified sampling based on

Convert a float column with nan to int pandas

I am trying to convert a float pandas column with nans to int format, using apply. I would like to use something like this: df.col = df.col.apply(to_integer) w

rename certain value in pandas series

I have the following panda Series: print(df.head()) Country Energy Supply Energy Supply per Capita % Renewable 0 Afghanistan 3.210000e+08

Changing values in columns based on their previous marker

I have the following dataframe: df = {'id': [1,2,3,4], '1': ['Green', 'Green', 'Green', 'Green'], '2': ['34','67', 'Blue', '77'], '3': ['Blue', '45', '9

“.. in pandas..html.py .. self.fmt.col_space.items()”: AttributeError: 'NoneType' object has no attribute 'items'

I'm trying to find out error in a word similarity calculation. def word_similarity_error_analysis(eval_df): eval_df['distance_rank'] = _normalized_ranking(e

All possible combinations of columns in dataframe -pandas/python

I'm trying to take one dataframe and create another, with all possible combinations of the columns and the difference between the corresponding values, i.e on 1

Converting column values to rows [duplicate]

I have a dataset where all values in column B are the same. It looks like this: A B 0 Marble Hill Pizza Place 1 Ch

'Series' object has no attribute 'values_counts'

When I try to apply the values_count() method to series within a function, I am told that 'Series' object has no attribute 'values_counts'. def replace_1_occ_f

How to fix Python error "...failed to map segment from shared object" appearing when I try to import NumPy library on GCP?

I've recently started to use Google Cloud Platform and I run my python scripts in Cloud Shell within Linux environment. By running one of the scripts that is u

NetworkX - Setting node attributes from dataframe

I'm having trouble figuring out how to add attributes to nodes in my network from columns in my dataframe. I have provided an example of my dataframe below, t

How to get all Sundays on dates in pandas and extract the corresponding values with it then save as new dataframe and do subtraction

I have a dataframe with 3 columns: file = glob.glob('InputFile.csv') for i in file: df = pd.read_csv(i) df['Date'] = pd.to_datetime(df['Date']) pri

How to get all Sundays on dates in pandas and extract the corresponding values with it then save as new dataframe and do subtraction

I have a dataframe with 3 columns: file = glob.glob('InputFile.csv') for i in file: df = pd.read_csv(i) df['Date'] = pd.to_datetime(df['Date']) pri

How to melt groups of columns along with adding columns specifying the column name where the values come from?

I want to be able to convert a wide form dataframe to long form, but while doing that I also want to add columns that specify the column names where the values

using time zone in pandas to_datetime

I have time from epochs timestamps I use data.Time_req = pd.to_datetime(data.Time_req) But I get UTC time, I need +5:30 from the given time. How do I tell panda