Category "pandas"

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

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