Category "pandas"

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

How to convert the values of an attribute having categorical values to integer type?

I have a dataset in which one of its columns is Ex-Showroom_Price, and I'm trying to convert its values to integers but I'm getting an error. import pandas as p

Postgres 9.5 upsert command in pandas or psycopg2?

Most of the examples I see are people inserting a single row into a database with the ON CONFLICT DO UPDATE syntax. Does anyone have any examples using SQLAlch

pandas installation error using pip installer

I am getting following error repeatedly while installing pandas through pip installer for python 3.7 in command prompt Using cached https://files.pythonhosted.

What is the difference between `pandas.Series.ravel()`, `pandas.Series.to_numpy()`, `pandas.Series.values` and `pandas.Series.array`?

Basically the title sums it up. I have created a dummy pandas.Series object and looked up all these properties and methods. Documentation states that all of the

Overwrite columns in DataFrames of different sizes pandas

I have following two Data Frames: df1 = pd.DataFrame({'ids':[1,2,3,4,5],'cost':[0,0,1,1,0]}) df2 = pd.DataFrame({'ids':[1,5],'cost':[1,4]}) And I want to upd

Python:Pandas - Object to string type conversion in dataframe

I'm trying to convert object to string in my dataframe using pandas. Having following data: particulars NWCLG 545627 ASDASD KJKJKJ ASDASD TGS/ASDWWR42045645010

Dropping df 's rows inside an iterrows() function does'nt work

I have a pandas dataframe df1 and I want to create a new df2 with columns created from df1 's rows values : DAT_RUN DAT_FORECAST LIB_SOURCE TEMPERATURE_