id
stringlengths
7
11
source
stringclasses
1 value
category
stringclasses
11 values
title
stringlengths
15
214
text
stringlengths
70
30.5k
url
stringlengths
57
160
tags
stringlengths
3
113
created_at
int64
1.22B
1.79B
se_79995432
stackoverflow
DATA_SCIENCE
xarray change subset of values of Dataset variable obtained from pandas DataFrame inconsistent with pandas v3
xarray change subset of values of Dataset variable obtained from pandas DataFrame inconsistent with pandas v3 The following is from the xarray documentation on "Assigning values with indexing": ds = xr.tutorial.open_dataset("air_temperature") # requires pooch # add an empty 2D dataarray ds["empty"] = xr.full_like(ds....
https://stackoverflow.com/questions/79995432/xarray-change-subset-of-values-of-dataset-variable-obtained-from-pandas-datafram
python, pandas, python-xarray
1,786,828,762
se_79995253
stackoverflow
DATA_SCIENCE
Create a new column in pandas conditionally based on two other columns that may have overlapping values
Create a new column in pandas conditionally based on two other columns that may have overlapping values In a dataset that contains X and Y coordinates, I want to assign a value in a new column based on the (X,Y) pair in a given row. Imagine a data set that contains the red points shown in the image below: Above, the ...
https://stackoverflow.com/questions/79995253/create-a-new-column-in-pandas-conditionally-based-on-two-other-columns-that-may
python, pandas, numpy
1,786,759,916
se_66265804
stackoverflow
DATA_SCIENCE
Convert lists of Coordinates to Polygons with GeoPandas
Convert lists of Coordinates to Polygons with GeoPandas I got lists of coordinates in the csv file(please click the pic). How should I convert them to polygons in GeoDataFrame? Below is the coordinates of one polygon and I have thousands rows of this. [118.103198,24.527338],[118.103224,24.527373],[118.103236,24.527366...
https://stackoverflow.com/questions/66265804/convert-lists-of-coordinates-to-polygons-with-geopandas
python, pandas, geopandas
1,613,672,166
se_78484934
stackoverflow
DATA_SCIENCE
How can I do a rolling product of a non-fixed frequency?
How can I do a rolling product of a non-fixed frequency? I am trying to do a simple rolling multiplication of a dataframe. (Each new value should be the product of all the input values in the window.) Realizing that rolling does not allow for products, I tried to look for alternate solutions but they seem not to work ...
https://stackoverflow.com/questions/78484934/how-can-i-do-a-rolling-product-of-a-non-fixed-frequency
python, pandas, rolling-computation
1,715,786,413
se_75478619
stackoverflow
DATA_SCIENCE
On Linux, use Python to edit excel file that contains formulas and then read the resulting values
On Linux, use Python to edit excel file that contains formulas and then read the resulting values So I have an excel file (.xlsx) on a Linux machine, and that excel file contains cells with formulas. What I would like to do is edit an input cell's value (i.e. not a formula cell, just a regular cell that contains a sim...
https://stackoverflow.com/questions/75478619/on-linux-use-python-to-edit-excel-file-that-contains-formulas-and-then-read-the
python, python-3.x, pandas, openpyxl, xlwings
1,676,587,241
se_79993566
stackoverflow
DATA_SCIENCE
Filter out rows from a DataFrame if value in columns X and Y match MultiIndex A and B
Filter out rows from a DataFrame if value in columns X and Y match MultiIndex A and B I have a DataFrame "A" containing the results of searching a database of test data such that: TEST RECORDING FILENAME 0 1 1 qwer.xlsx 1 1 2 asdf.xlsx 2 2 1 zxcv.xlsx 3 2 2 tyui...
https://stackoverflow.com/questions/79993566/filter-out-rows-from-a-dataframe-if-value-in-columns-x-and-y-match-multiindex-a
python, pandas, dataframe
1,786,551,852
se_79692191
stackoverflow
DATA_SCIENCE
In Python, how to find difference between a specific column in one dataframe and numeric columns of another dataframe?
In Python, how to find difference between a specific column in one dataframe and numeric columns of another dataframe? I have two datasets/dataframes df1 and df2, I want to generate df3 by finding the difference between numeric columns of df2 and df1's column_X. #### copy and paste below to generate df1 and df2 impor...
https://stackoverflow.com/questions/79692191/in-python-how-to-find-difference-between-a-specific-column-in-one-dataframe-and
python, pandas, for-loop, apply
1,751,846,436
se_79992093
stackoverflow
DATA_SCIENCE
pandas running notnull() sum() versus count() against the dataframe
pandas running notnull() sum() versus count() against the dataframe I’ve always assumed df.notnull().sum() and df.notnull().count() would return the same value. Here is a snippet of a code for illustration: import pandas as pd data = { 'Name': ['Alice', 'Bob', None, 'Diane'], 'Age': [25, None, 27, 31], 'Salar...
https://stackoverflow.com/questions/79992093/pandas-running-notnull-sum-versus-count-against-the-dataframe
python, pandas, notnull
1,786,413,061
se_68632108
stackoverflow
DATA_SCIENCE
How to convert a dict into a pandas multiindex dataframe
How to convert a dict into a pandas multiindex dataframe I´m handling distances between elements (e.g. a1,a2, ...) of different attributes (e.g. A, B, ...) and I choose a dict to store the distances. The dict has the following form: mydict = {('A', ('a1','a2')): 1.0, ('A', ('a1','a3')): 0.5, ('A', ...
https://stackoverflow.com/questions/68632108/how-to-convert-a-dict-into-a-pandas-multiindex-dataframe
python, pandas, crosstab
1,627,976,457
se_24988131
stackoverflow
DATA_SCIENCE
Nested dictionary to multiindex dataframe where dictionary keys are column labels
Nested dictionary to multiindex dataframe where dictionary keys are column labels Say I have a dictionary that looks like this: dictionary = {'A': {'a': [1,2,3,4,5], 'b': [6,7,8,9,1]}, 'B': {'a': [2,3,4,5,6], 'b': [7,8,9,1,2]}} and I want a dataframe that looks so...
https://stackoverflow.com/questions/24988131/nested-dictionary-to-multiindex-dataframe-where-dictionary-keys-are-column-label
python, dictionary, pandas, dataframe, multi-index
1,406,518,982
se_51828811
stackoverflow
DATA_SCIENCE
How to convert data from txt files to Excel files using python
How to convert data from txt files to Excel files using python I have a text file that contains data like this. It is is just a small example, but the real one is pretty similar. I am wondering how to display such data in an "Excel Table" like this using Python?
https://stackoverflow.com/questions/51828811/how-to-convert-data-from-txt-files-to-excel-files-using-python
python, pandas
1,534,186,319
se_59170655
stackoverflow
DATA_SCIENCE
Python Pandas - Custom Calcs for Total row
Python Pandas - Custom Calcs for Total row I have the following code which is working as desired with one exception df['FPYear'] = df['First_Purchase_Date'].dt.year Table2 = df.loc[df.Date.between('2014-01-01','2019-11-30')].groupby(df['FPYear'])[['New Customer', 'Existing Customer', 'revenue']].sum() #with date fil...
https://stackoverflow.com/questions/59170655/python-pandas-custom-calcs-for-total-row
python, pandas, group-by
1,575,443,370
se_78225231
stackoverflow
DATA_SCIENCE
What is the cause of my error "Expected a 2-dimensional container but got <class 'pandas.core.series.Series'> instead."
What is the cause of my error "Expected a 2-dimensional container but got <class 'pandas.core.series.Series'> instead." My code uses scikit-learn fit. I tried to look up this error code online, but couldn't find much information about it. What I understand is that I have to make one Dataframe f...
https://stackoverflow.com/questions/78225231/what-is-the-cause-of-my-error-expected-a-2-dimensional-container-but-got-class
python, pandas, dataframe, scikit-learn
1,711,455,089
se_44760256
stackoverflow
DATA_SCIENCE
Pandas Equivalent to SQL YEAR(GETDATE())
Pandas Equivalent to SQL YEAR(GETDATE()) I'm a Pandas newbie but decent at SQL. A function I often leverage in SQL is this: YEAR(date_format_data) = (YEAR(GETDATE())-1) This will get me all the data from last year. How can I do the equivalent in Pandas? Here's some example data: Date Number 01/01/15 1 01/02/15 ...
https://stackoverflow.com/questions/44760256/pandas-equivalent-to-sql-yeargetdate
python-3.x, sorting, date, pandas, filter
1,498,481,665
se_45506038
stackoverflow
DATA_SCIENCE
Pandas Reindex to Fill Missing Dates, or Better Method to Fill?
Pandas Reindex to Fill Missing Dates, or Better Method to Fill? My data is absence records from a factory. Some days there are no absences so there is no data or date recorded for that day. However, and where this gets hairy with the other examples shown, is on any given day there can be several absences for various...
https://stackoverflow.com/questions/45506038/pandas-reindex-to-fill-missing-dates-or-better-method-to-fill
python, pandas, group-by
1,501,847,231
se_49254224
stackoverflow
DATA_SCIENCE
How to use RE OR Operand for Pandas RE .str.extract()
How to use RE OR Operand for Pandas RE .str.extract() I've tried re-reading through the Python RE documentation before asking and searching around but don't see a duplicate question so far (which surprised me). Outside of a DataFrame I have my re working example here: x = 'my best friend's birthday is 24 Jan 2001.' pr...
https://stackoverflow.com/questions/49254224/how-to-use-re-or-operand-for-pandas-re-str-extract
python, regex, pandas, date, operands
1,520,938,180
se_70897432
stackoverflow
DATA_SCIENCE
Calculating calendar weeks from fiscal weeks
Calculating calendar weeks from fiscal weeks So I am really new to this and struggling with something, which I feel should be quite simple. I have a Pandas Dataframe containing two columns: Fiscal Week (str) and Amount sold (int). Fiscal Week Amount sold 0 2019031 24 1 2019041 47 2 2019221 34 3 2019231 ...
https://stackoverflow.com/questions/70897432/calculating-calendar-weeks-from-fiscal-weeks
python, pandas, string, datetime
1,643,389,261
se_79951141
stackoverflow
DATA_SCIENCE
Getting the average of rows based on DateTimeIndex
Getting the average of rows based on DateTimeIndex I have a dataframe like: Date Number 2008-01-01 5 2008-02-01 55 2008-03-01 6 2008-04-01 10 where the DatetimeIndex is in year-month-day format. I would like to compute the average of every two consecutive Numbers. My dataframe has hundreds of rows, so ...
https://stackoverflow.com/questions/79951141/getting-the-average-of-rows-based-on-datetimeindex
python, pandas, time-series, datetimeindex
1,780,537,743
se_51878601
stackoverflow
DATA_SCIENCE
pandas: dataframe to_csv, how to set column names
pandas: dataframe to_csv, how to set column names Code snippet: import numpy as np import pandas as pd myseries=pd.Series(np.random.randn(5)) df=pd.DataFrame(myseries) df.to_csv("output.csv") Output: 0 0 0.51.. 1 0.14.. 2 -0.68.. 3 0.48.. 4 1.89.. I want the column name to be "values" instea...
https://stackoverflow.com/questions/51878601/pandas-dataframe-to-csv-how-to-set-column-names
python, pandas, csv, dataframe
1,534,427,147
se_13446480
stackoverflow
DATA_SCIENCE
Python Pandas: remove entries based on the number of occurrences
Python Pandas: remove entries based on the number of occurrences I'm trying to remove entries from a data frame which occur less than 100 times. The data frame data looks like this: pid tag 1 23 1 45 1 62 2 24 2 45 3 34 3 25 3 62 Now I count the number of tag occurrences like ...
https://stackoverflow.com/questions/13446480/python-pandas-remove-entries-based-on-the-number-of-occurrences
python, numpy, python-2.7, pandas
1,353,288,007
se_40427943
stackoverflow
DATA_SCIENCE
How do I change a single index value in pandas dataframe?
How do I change a single index value in pandas dataframe? energy.loc['Republic of Korea'] I want to change the value of index from 'Republic of Korea' to 'South Korea'. But the dataframe is too large and it is not possible to change every index value. How do I change only this single value?
https://stackoverflow.com/questions/40427943/how-do-i-change-a-single-index-value-in-pandas-dataframe
python, pandas, data-analysis
1,478,278,204
se_57017469
stackoverflow
DATA_SCIENCE
Solving 'Unrecognized Token' Error While Using SQLite Insert Command
Solving 'Unrecognized Token' Error While Using SQLite Insert Command I keep getting an OperationalError: Unrecognized Token. The error hapens when I'm attempting to insert data into my SQLite database using an SQLite Insert command. What do I need to do to correct this error or is there a better way I should ...
https://stackoverflow.com/questions/57017469/solving-unrecognized-token-error-while-using-sqlite-insert-command
python, pandas, pysqlite
1,563,006,592
se_79989760
stackoverflow
DATA_SCIENCE
null value return for selected columns of a DataFrame
null value return for selected columns of a DataFrame I am trying to group by a dataframe of Adressess as object and Pricees as float. These are mycolumns in a larger dataframe but when I am trying to seperate the columns (Address and Price) from other columns in the larger DataFrame, the Price column values shows NaN...
https://stackoverflow.com/questions/79989760/null-value-return-for-selected-columns-of-a-dataframe
python, pandas, dataframe
1,785,613,107
se_52382901
stackoverflow
DATA_SCIENCE
Read excel cell values containing formulae with pandas
Read excel cell values containing formulae with pandas I am trying to read an Excel sheet with pandas but because it has formulae it will return NaN values when reading it instead of the cell values. df=pd.read_excel('Test.xlsx',sheet_name='Sheet1')
https://stackoverflow.com/questions/52382901/read-excel-cell-values-containing-formulae-with-pandas
python, pandas, xlsx
1,537,261,573
se_74825685
stackoverflow
DATA_SCIENCE
python pandas: using pd.IndexSlice for both rows and columns in a double multiindex dataframe
python pandas: using pd.IndexSlice for both rows and columns in a double multiindex dataframe I have a double Multiindex dataframe as follows. I slice the rows with idx = pd.IndexSlice but I don't know how to do the same with the columns. So provided this data: df = pd.DataFrame(data=pd.DataFrame(data=np.random.randin...
https://stackoverflow.com/questions/74825685/python-pandas-using-pd-indexslice-for-both-rows-and-columns-in-a-double-multiin
python, pandas, slice, multi-index
1,671,200,222
se_56238200
stackoverflow
DATA_SCIENCE
How can extract data from .h5 file and save it in .txt or .csv properly?
How can extract data from .h5 file and save it in .txt or .csv properly? After searching a lot I couldn't find a simple way to extract data from .h5 and pass it to a data.Frame by Numpy or Pandas in order to save in .txt or .csv file. import h5py import numpy as np import pandas as pd filename = 'D:\data.h5' f = h5p...
https://stackoverflow.com/questions/56238200/how-can-extract-data-from-h5-file-and-save-it-in-txt-or-csv-properly
python, pandas, numpy, hdf5, data-extraction
1,558,441,310
se_79989470
stackoverflow
DATA_SCIENCE
Apply a user-defined function (UDF) to Pandas
Apply a user-defined function (UDF) to Pandas I want to apply the function to Pandas, where UDF is assessing multiple strings, I have tried the following, which works, but not ideal since if there is long list then one has to keep on adding OR statement. def tran_cat(x): # if x['Desc'].str.contains('|'.join(["Coco...
https://stackoverflow.com/questions/79989470/apply-a-user-defined-function-udf-to-pandas
python, pandas, user-defined-functions
1,785,498,278
se_30944577
stackoverflow
DATA_SCIENCE
Check if string is in a pandas dataframe
Check if string is in a pandas dataframe I would like to see if a particular string exists in a particular column within my dataframe. I'm getting the error ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). import pandas as pd baby_data_set = [('Bob', 968), (...
https://stackoverflow.com/questions/30944577/check-if-string-is-in-a-pandas-dataframe
python, pandas
1,434,737,045
se_62669003
stackoverflow
DATA_SCIENCE
transpose/stack/unstack pandas dataframe whilst concatenating the field name with existing columns
transpose/stack/unstack pandas dataframe whilst concatenating the field name with existing columns I have a dataframe that looks something like: Component Date MTD YTD QTD FC ABC Jan 2017 56 nan nan nan DEF Jan 2017 453 nan nan nan XYZ Jan 2017 ...
https://stackoverflow.com/questions/62669003/transpose-stack-unstack-pandas-dataframe-whilst-concatenating-the-field-name-wit
python, pandas, stack, transpose
1,593,572,519
se_38089010
stackoverflow
DATA_SCIENCE
Merge a list of pandas dataframes
Merge a list of pandas dataframes I have a list of data frames and I need to merge them together using a unique column (date). Field names are different so concat is out. I can manually use df[0].merge(df[1], on='Date').merge(df[3], on='Date') etc. to merge each df one by one, but the issue is that the number of data...
https://stackoverflow.com/questions/38089010/merge-a-list-of-pandas-dataframes
python, pandas, dataframe, join
1,467,165,070
se_50941409
stackoverflow
DATA_SCIENCE
Quote marks in bash file created in Python
Quote marks in bash file created in Python I'm using Python and Pandas to write multiple bash scripts. I have a pandas.Series containing the script. Simplified:: script = pd.Series([ '#!/bin/bash', '#SBATCH --output "/home/path/output_filename.out"' ]) I then use script.to_csv('script_file.bat',index=False) to crea...
https://stackoverflow.com/questions/50941409/quote-marks-in-bash-file-created-in-python
python, string, bash, pandas, quotes
1,529,475,219
se_55435469
stackoverflow
DATA_SCIENCE
Combining iloc and loc
Combining iloc and loc I am trying to combine iloc and loc; is there possibility? Specifically I would like to: give integer in the form :train_size for the rows values give a list with the column names for the column values (replacing [0, 1] in the code below) training_set = dataset.iloc[:train_size, [0, 1]].valu...
https://stackoverflow.com/questions/55435469/combining-iloc-and-loc
python, pandas, indexing
1,553,978,355
se_76230048
stackoverflow
DATA_SCIENCE
How do I combine .loc and .iloc in Pandas?
How do I combine .loc and .iloc in Pandas? I have a Pandas dataframe that looks like this: id color shape person 0 1 Green Circle Sally 1 17 Blue Square Bob 2 19 Orange Circle Tim 3 17 Yellow Triangle Sue 4 22 White Rectangle ...
https://stackoverflow.com/questions/76230048/how-do-i-combine-loc-and-iloc-in-pandas
python, pandas, indexing
1,683,824,777
se_68669062
stackoverflow
DATA_SCIENCE
Pandas read_xml and SEPA (CAMT 053) XML
Pandas read_xml and SEPA (CAMT 053) XML Recently I wanted to try the newly implemented xml_read function within pandas. I thought about testing the feature with SEPA camt-format xml. I'm stuck with the functions parameters, as I'm unfamiliar with the lxml logic. I tried pointing to the transactions values as rows ("Nt...
https://stackoverflow.com/questions/68669062/pandas-read-xml-and-sepa-camt-053-xml
python-3.x, pandas, xml, xml-parsing
1,628,175,673
se_13148429
stackoverflow
DATA_SCIENCE
How can I change the order of DataFrame columns?
How can I change the order of DataFrame columns? I have the following DataFrame (df): import numpy as np import pandas as pd df = pd.DataFrame(np.random.rand(10, 5)) I add more column(s) by assignment: df['mean'] = df.mean(1) How can I move the column mean to the front, i.e. set it as first column leaving the order...
https://stackoverflow.com/questions/13148429/how-can-i-change-the-order-of-dataframe-columns
python, pandas, dataframe, sorting, indexing
1,351,635,779
se_64897689
stackoverflow
DATA_SCIENCE
How to have pandas perform a rolling average on a non-uniform x-grid
How to have pandas perform a rolling average on a non-uniform x-grid I would like to perform a rolling average but with a window that only has a finite 'vision' in x. I would like something similar to what I have below, but I want a window range that based on the x value rather than position index. While doing this wi...
https://stackoverflow.com/questions/64897689/how-to-have-pandas-perform-a-rolling-average-on-a-non-uniform-x-grid
python, pandas, numpy, scipy
1,605,718,639
se_79982061
stackoverflow
DATA_SCIENCE
Change multiple values in the same column
Change multiple values in the same column df['frequency_of_purchases'] = df['frequency_of_purchases'].str.replace('Fortnightly', 'Bi-Weekly') df['frequency_of_purchases'] = df['frequency_of_purchases'].str.replace('Every 3 Months', 'Quaterly') How can I make these changes in a single line?
https://stackoverflow.com/questions/79982061/change-multiple-values-in-the-same-column
pandas
1,784,486,132
se_79982220
stackoverflow
DATA_SCIENCE
Pandas df.info() shows None in Streamlit while head() and shape work correctly
Pandas df.info() shows None in Streamlit while head() and shape work correctly I am practicing Pandas with Streamlit in Notepad++. Methods like df.shape, df.head(), df.tail(), and df.columns display correctly in the Streamlit web browser. However, when I try to display df.info(), Streamlit shows None instead of the Da...
https://stackoverflow.com/questions/79982220/pandas-df-info-shows-none-in-streamlit-while-head-and-shape-work-correctly
python, pandas, dataframe, streamlit
1,784,547,506
se_62012615
stackoverflow
DATA_SCIENCE
Convert a hmmer --tblout output to a pandas dataframe
Convert a hmmer --tblout output to a pandas dataframe Is there a way to convert a hmmer output to a pandas dataframe? I am also unsure how to load a hmmer tblout table into python via the Bio module. I believe you can call a hmmer format with SeqIO.parse or SeqIO.search.The format of the table appears tab separated ...
https://stackoverflow.com/questions/62012615/convert-a-hmmer-tblout-output-to-a-pandas-dataframe
python, pandas, dataframe, bioinformatics, biopython
1,590,451,424
se_40160149
stackoverflow
DATA_SCIENCE
reading RDa file in python as a pandas data frame
reading RDa file in python as a pandas data frame I have an RDa file that I created in R. I want to read this file on python as a pandas dataframe. I have the following code to do the same: import rpy2.robjects as robjects import numpy as np from rpy2.robjects import pandas2ri pandas2ri.activate() # load your file r...
https://stackoverflow.com/questions/40160149/reading-rda-file-in-python-as-a-pandas-data-frame
python, r, pandas, dataframe, rpy2
1,476,982,178
se_79966690
stackoverflow
DATA_SCIENCE
pandas read_xml - handling nested nodes beyond level 2
pandas read_xml - handling nested nodes beyond level 2 I am using Pandas to import xml files into a Postgres database via the .read_xml() and .to_sql() functions. With two levels of nested elements in my xml files, things work as I expect: <table1> <id>1</id> <label>Label 1</label> <id>2</id> <label>Label ...
https://stackoverflow.com/questions/79966690/pandas-read-xml-handling-nested-nodes-beyond-level-2
python, pandas, readxml
1,782,371,034
se_79943913
stackoverflow
DATA_SCIENCE
Copying dataframe during EDA
Copying dataframe during EDA Look, I have the following problem: currently, I am learning Data Science via Online Course and I have observed that during explaratory data analysis for subsequent model training, I filted pandas dataframe many times. Initally, I have dataframe called 'df' and then I do make some data fil...
https://stackoverflow.com/questions/79943913/copying-dataframe-during-eda
python, pandas, dataframe, filter
1,779,267,538
se_79950565
stackoverflow
DATA_SCIENCE
How do I look into https://raw.githubusercontent.com/python-visualization/folium/master/examples/data to see available data?
How do I look into https://raw.githubusercontent.com/python-visualization/folium/master/examples/data to see available data? I am learning how to create maps using python and a lot of the examples I learn from use https://raw.githubusercontent.com/python-visualization/folium/master/examples/data as an example dataset...
https://stackoverflow.com/questions/79950565/how-do-i-look-into-https-raw-githubusercontent-com-python-visualization-folium
python, pandas, dataframe, github, folium
1,780,447,181
se_79951097
stackoverflow
DATA_SCIENCE
&quot;import matplotlib.pyplot as plt&quot; &amp; &quot;import meteostat as ms&quot; script not running
&quot;import matplotlib.pyplot as plt&quot; &amp; &quot;import meteostat as ms&quot; script not running In my Visual Studio Code is not importing these programs with the following script import matplotlib.pyplot as plt import meteostat as ms Are there "pandas" or "pip" commands I need to run this?
https://stackoverflow.com/questions/79951097/import-matplotlib-pyplot-as-plt-import-meteostat-as-ms-script-not-running
python, pandas, matplotlib, meteostat
1,780,523,016
se_57006437
stackoverflow
DATA_SCIENCE
Calculate RSI indicator from pandas DataFrame?
Calculate RSI indicator from pandas DataFrame? My problem I tried many libraries on Github but all of them did not produce matching results for TradingView so I followed the formula on this link to calculate RSI indicator. I calculated it with Excel and collated the results with TradingView. I know it's absolutely co...
https://stackoverflow.com/questions/57006437/calculate-rsi-indicator-from-pandas-dataframe
python, pandas, dataframe
1,562,932,272
se_79950423
stackoverflow
DATA_SCIENCE
python dataframe rolling by date to get sum
python dataframe rolling by date to get sum I need to accumulate the sum of transaction amount looking back a set number of days. 10 days would be a start. I have petty cash transaction for a couple of people and I want to sum their spending for a rolling period of dates. Issue: the transactions must be group by "...
https://stackoverflow.com/questions/79950423/python-dataframe-rolling-by-date-to-get-sum
python, pandas, dataframe
1,780,422,804
se_78516620
stackoverflow
DATA_SCIENCE
Reading .xlsx results in a ValueError: Unable to read workbook. This is most probably because the workbook source files contain some invalid XML
Reading .xlsx results in a ValueError: Unable to read workbook. This is most probably because the workbook source files contain some invalid XML I'm trying to read and clean an Excel workbook that contains an image. My goal is to process it automatically, as I have many similar files. I used the following code to read...
https://stackoverflow.com/questions/78516620/reading-xlsx-results-in-a-valueerror-unable-to-read-workbook-this-is-most-pro
python, excel, pandas
1,716,371,042
se_42504442
stackoverflow
DATA_SCIENCE
TypeError: &#39;Series&#39; objects are mutable, thus they cannot be hashed
TypeError: &#39;Series&#39; objects are mutable, thus they cannot be hashed I know this error is common, I tried some solutions I looked up and still can't understand what is wrong. I guess it is due to the mutable form of row and row1, but i can't figure it out What am I trying to do ? I have 2 dataframes. I need to...
https://stackoverflow.com/questions/42504442/typeerror-series-objects-are-mutable-thus-they-cannot-be-hashed
python, pandas, hash, immutability
1,488,272,980
se_71016184
stackoverflow
DATA_SCIENCE
Compare 2 columns in same excel sheet in pandas
Compare 2 columns in same excel sheet in pandas In excel sheet i want to compare the 2 columns. The column names like file_1 and file_2. by using these 2 cols want to create the another col like 'diff' by using excel formula [countifs]. In case , if file_1 and file_2 column records matched it should be 0 (Zero) in dif...
https://stackoverflow.com/questions/71016184/compare-2-columns-in-same-excel-sheet-in-pandas
python, pandas, dataframe, pandas-groupby, isin
1,644,226,027
se_79980955
stackoverflow
DATA_SCIENCE
FastAPI returning &quot;Out of range float values are not JSON compliant&quot; with Pandas NaN values
FastAPI returning &quot;Out of range float values are not JSON compliant&quot; with Pandas NaN values I am building a FastAPI endpoint that reads data, processes it into a Pandas DataFrame, and returns it as a JSON response. However, my dataset contains missing data (NaN). When I convert the DataFrame to a dictionary ...
https://stackoverflow.com/questions/79980955/fastapi-returning-out-of-range-float-values-are-not-json-compliant-with-pandas
python, json, pandas, fastapi, nan
1,784,112,015
se_79890933
stackoverflow
DATA_SCIENCE
How to merge N DataFrames into one, while using first DF as reference?
How to merge N DataFrames into one, while using first DF as reference? I am trying to fuse N dataframes to create a single table for future analysis. Right now N = 8, but soon N = 500+ I have multiple datasets, and I wrote code that counted how many times unique Objects appeared in them. First DF is a single column th...
https://stackoverflow.com/questions/79890933/how-to-merge-n-dataframes-into-one-while-using-first-df-as-reference
python, pandas, dataframe
1,771,336,241
se_50643386
stackoverflow
DATA_SCIENCE
Easy Way to See if Two Columns are One-to-One in Pandas
Easy Way to See if Two Columns are One-to-One in Pandas Working with data in Python 3+ with pandas. It seems like there should be an easy way to check if two columns have a one-to-one relationship (regardless of column type), but I'm struggling to think of the best way to do this. Example of expected output: A B ...
https://stackoverflow.com/questions/50643386/easy-way-to-see-if-two-columns-are-one-to-one-in-pandas
python, pandas, one-to-one
1,527,855,915
se_55577098
stackoverflow
DATA_SCIENCE
Track the historic of a time series for a market sentiment trading strategy. Error: argument of type &#39;numpy.bool_&#39; is not iterable
Track the historic of a time series for a market sentiment trading strategy. Error: argument of type &#39;numpy.bool_&#39; is not iterable I'm developing a market sentiment trading strategy for my Investment class. Basically, the strategy currently consists of selling the market index in Zone 1 and 3 and buying (holdi...
https://stackoverflow.com/questions/55577098/track-the-historic-of-a-time-series-for-a-market-sentiment-trading-strategy-err
python, pandas, quantitative-finance, trading
1,554,738,028
se_79979626
stackoverflow
DATA_SCIENCE
How can I boxplot values that wrap around using matplotlib?
How can I boxplot values that wrap around using matplotlib? I want to show the distribution of angle estimations using a boxplot. The problem is that angles wrap around (I chose +-180° as the wrapping point, but the same applies to 0/360°). Matplotlibs boxplot method interprets the angles as linear values, which leads...
https://stackoverflow.com/questions/79979626/how-can-i-boxplot-values-that-wrap-around-using-matplotlib
python, pandas, numpy, matplotlib, angle
1,783,680,773
se_50800454
stackoverflow
DATA_SCIENCE
How can I download stock price data with Python?
How can I download stock price data with Python? I have installed pandas-datareader but I'm wondering if there are alternatives. So far, I'm using this: import pandas_datareader.data as web start_date = '2018-01-01' end_date = '2018-06-08' panel_data = web.DataReader('SPY', 'yahoo', start_date, end_date)
https://stackoverflow.com/questions/50800454/how-can-i-download-stock-price-data-with-python
tooling-recommendation, python, pandas, stock, pandas-datareader
1,528,728,458
se_42818262
stackoverflow
DATA_SCIENCE
Pandas DataFrame Replace NaT with None
Pandas DataFrame Replace NaT with None I have been struggling with this question for a long while, and I tried different methods. I have a simple DataFrame as shown, I can use code to replace NaN with None (Not String "None"), [![dfTest2 = dfTest.where(pd.notnull(dfTest), None)][2]][2] I support that NaT is also cl...
https://stackoverflow.com/questions/42818262/pandas-dataframe-replace-nat-with-none
python, pandas, dataframe
1,489,603,661
se_20262448
stackoverflow
DATA_SCIENCE
How to write to an existing excel file without breaking formulas with openpyxl?
How to write to an existing excel file without breaking formulas with openpyxl? When you write to an excel file from Python in the following manner: import pandas from openpyxl import load_workbook book = load_workbook('Masterfile.xlsx') writer = pandas.ExcelWriter('Masterfile.xlsx') writer.book = book writer.sheet...
https://stackoverflow.com/questions/20262448/how-to-write-to-an-existing-excel-file-without-breaking-formulas-with-openpyxl
python, excel, pandas, openpyxl
1,385,631,534
se_50353740
stackoverflow
DATA_SCIENCE
pandas to_excel() ignore/allow duplicate column names
pandas to_excel() ignore/allow duplicate column names Is there way to ignore duplicate column names after using to_excel() function of pandas? Say, I have old_wb.xlsx: >> df1 = pd.read_excel('wb1.xlsx') ---------------------merged header-------------------- col1 col2 col3 col1 col4 col1 ...
https://stackoverflow.com/questions/50353740/pandas-to-excel-ignore-allow-duplicate-column-names
python, excel, pandas
1,526,397,263
se_57314254
stackoverflow
DATA_SCIENCE
Pandas df write to Excel template with prepared styles
Pandas df write to Excel template with prepared styles I have DataFrame df. I have Excel file template_with_styles.xlsx in which there is a color table ready. I want to write df to a template. from openpyxl.utils.dataframe import dataframe_to_rows wb = load_workbook('template_with_styles.xlsx') ws = wb.active for ...
https://stackoverflow.com/questions/57314254/pandas-df-write-to-excel-template-with-prepared-styles
python, excel, pandas, dataframe, openpyxl
1,564,680,846
se_78246082
stackoverflow
DATA_SCIENCE
Matplotlib: Legend for marker and color in a scatterplot
Matplotlib: Legend for marker and color in a scatterplot I am trying to plot a scatterplot for the data frame(posted below). I want to represent the scatterplot with the different stages being shown as different markers(circle,square etc) and different products being shown as different colors(red,blue etc). so far i h...
https://stackoverflow.com/questions/78246082/matplotlib-legend-for-marker-and-color-in-a-scatterplot
python, pandas, matplotlib, scatter-plot
1,711,749,205
se_40442014
stackoverflow
DATA_SCIENCE
Pandas ValueError Arrays Must be All Same Length
Pandas ValueError Arrays Must be All Same Length Iterates over a big list of .mp3 links to get the metadata tags and save it to an Excel file. Results in this error. I appreciate any help. Thanks. df = pd.DataFrame({ 'Links': lines, 'Titles': titles, 'Singers': finalsingers, 'Albums': finalalbums, ...
https://stackoverflow.com/questions/40442014/pandas-valueerror-arrays-must-be-all-same-length
python, pandas
1,478,372,256
se_77269618
stackoverflow
DATA_SCIENCE
Why does an operation on a large integer silently overflow?
Why does an operation on a large integer silently overflow? I have a list that contains very large integers and I want to cast it into a pandas column with a specific dtype. As an example, if the list contains 2**31, which is outside the limit of int32 dtype, casting it into dtype int32 throws an Overflow Error, which...
https://stackoverflow.com/questions/77269618/why-does-an-operation-on-a-large-integer-silently-overflow
python, pandas, long-integer
1,696,984,519
se_41271673
stackoverflow
DATA_SCIENCE
Format numbers in pandas as currency in thousands or millions
Format numbers in pandas as currency in thousands or millions I have a dataframe: pd.DataFrame({"Amount":[19000000, 9873200, 823449242]}), and I need to convert the numbers into currency ($) in millions. i.e. $19.00MM, $9.88MM, and $823.45MM. Does anyone know a quick way to do this? Thanks!
https://stackoverflow.com/questions/41271673/format-numbers-in-pandas-as-currency-in-thousands-or-millions
python, pandas, numbers, format, currency
1,482,353,413
se_59734555
stackoverflow
DATA_SCIENCE
Create pandas dataframe from multiple part-dataframes
Create pandas dataframe from multiple part-dataframes I'm trying to create a Pandas dataframe that is created of multiple smaller dataframes. All dataframes got the same Index variable but sometimes have different columns, which should be added if they don't exist yet. So basically a join (outer I guess) would be the ...
https://stackoverflow.com/questions/59734555/create-pandas-dataframe-from-multiple-part-dataframes
python, pandas
1,579,007,778
se_63557310
stackoverflow
DATA_SCIENCE
How to change column name in huge dataframe?
How to change column name in huge dataframe? I want to change the column name of the dataframe which has 128 columns. I want to iteratively change it. I want it to be facefeat_1, facefeat_2, ...., facefeat_128. Help would be appreciated. Thank you
https://stackoverflow.com/questions/63557310/how-to-change-column-name-in-huge-dataframe
python, pandas, dataframe
1,598,257,661
se_79975201
stackoverflow
DATA_SCIENCE
Which approaches should be used for monthly demand forecasting with few observations per product?
Which approaches should be used for monthly demand forecasting with few observations per product? community. How are you? I am a junior data analyst and I am working on a demand/revenue forecasting project for a factory. The goal of the project is to forecast, on a monthly basis, the number of units sold/invoiced per ...
https://stackoverflow.com/questions/79975201/which-approaches-should-be-used-for-monthly-demand-forecasting-with-few-observat
python, pandas, machine-learning, data-analysis
1,783,364,873
se_63596329
stackoverflow
DATA_SCIENCE
Python Pandas - Read csv with commented header line
Python Pandas - Read csv with commented header line I want to read and process a csv file with pandas. The file (as seen below) contains multiple header lines which are indicated by a # tag. I can import that file easily by using import pandas as pd file = "data.csv" data = pd.read_csv(file, delimiter="\s+", ...
https://stackoverflow.com/questions/63596329/python-pandas-read-csv-with-commented-header-line
python, pandas, csv, parsing, openfoam
1,598,440,105
se_65079545
stackoverflow
DATA_SCIENCE
Compare dataframe columns: TypeError: Cannot interpret &#39;StringDtype&#39; as a data type
Compare dataframe columns: TypeError: Cannot interpret &#39;StringDtype&#39; as a data type I am trying to compare two dataframes columns and types to check for equality, the rows are expected to be different. I am using pandas version 1.1.2 pd.__version__ '1.1.2' if (df1.columns.difference(df2.columns).empty) and ...
https://stackoverflow.com/questions/65079545/compare-dataframe-columns-typeerror-cannot-interpret-stringdtype-as-a-data-t
python, pandas, dataframe
1,606,762,686
se_39279439
stackoverflow
DATA_SCIENCE
Append dataframe to dict
Append dataframe to dict I've created a dict of dicts structured in such a way that the key is the department ('ABC') then the date (01.08) is the key and values are { product name (A), Units (0), Revenue (0)}. This structure continues for several departments. See dict of dict printout below. 'ABC': ...
https://stackoverflow.com/questions/39279439/append-dataframe-to-dict
python, pandas, dictionary
1,472,757,976
se_55188544
stackoverflow
DATA_SCIENCE
How to workaround &quot;error tokenizing data&quot;
How to workaround &quot;error tokenizing data&quot; A lot of questions have been already asked about this topic on SO. (and many others). Among the numerous answers, none of them was really helpful to me so far. If I missed the useful one, please let me know. I simply would like to read a CSV file with pandas into ...
https://stackoverflow.com/questions/55188544/how-to-workaround-error-tokenizing-data
python, pandas, csv
1,552,673,581
se_18327624
stackoverflow
DATA_SCIENCE
Find element&#39;s index in pandas Series
Find element&#39;s index in pandas Series I know this is a very basic question but for some reason I can't find an answer. How can I get the index of certain element of a Series in python pandas? (first occurrence would suffice) I.e., I'd like something like: import pandas as pd myseries = pd.Series([1,4,0,7,5], ind...
https://stackoverflow.com/questions/18327624/find-elements-index-in-pandas-series
python, pandas
1,376,976,834
se_79972288
stackoverflow
DATA_SCIENCE
How to Insert datas from a dataframe into a database?
How to Insert datas from a dataframe into a database? I have a DAG with three tasks in my project. The three tasks call three function which are in differents files. I'm using the ELT/ETL process. Everything seems fine until the injection of the datas. I don't know why I can't insert it in my database. I checked that ...
https://stackoverflow.com/questions/79972288/how-to-insert-datas-from-a-dataframe-into-a-database
python, pandas, sqlalchemy, airflow
1,782,928,885
se_42370977
stackoverflow
DATA_SCIENCE
How to save a new sheet in an existing excel file, using Pandas?
How to save a new sheet in an existing excel file, using Pandas? I want to use excel files to store data elaborated with python. My problem is that I can't add sheets to an existing excel file. Here I suggest a sample code to work with in order to reach this issue import pandas as pd import numpy as np path = r"C:\U...
https://stackoverflow.com/questions/42370977/how-to-save-a-new-sheet-in-an-existing-excel-file-using-pandas
python, pandas, openpyxl, xlsxwriter
1,487,689,624
se_52263102
stackoverflow
DATA_SCIENCE
enumerate items in each group
enumerate items in each group I have a DataFrame like id chi prop ord 0 100 L 67 0 1 100 L 68 1 2 100 L 68 2 3 100 L 68 3 4 100 L 70 0 5 100 L 71 0 6 100 R 67 0 7 100 R 68 1 8 100 R 68 2 9 100 R ...
https://stackoverflow.com/questions/52263102/enumerate-items-in-each-group
python, pandas, group-by
1,536,602,177
se_79921372
stackoverflow
DATA_SCIENCE
Pandas DataFrame Pivot, reset index
Pandas DataFrame Pivot, reset index I have a data-frame which looks in as simplified way like following: import pandas as pd df = pd.DataFrame({ 'catYM': [202601,202601,202602,202603,202603,202501,202501], 'prod': [20,26,34,45,18,19,20]}) print(df) catYM prod 0 202601 20 1 202601 26 2 202602 ...
https://stackoverflow.com/questions/79921372/pandas-dataframe-pivot-reset-index
pandas, dataframe, pivot
1,775,550,235
se_79972629
stackoverflow
DATA_SCIENCE
How to correctly type hint a python field that accepts a pandas Timestamp?
How to correctly type hint a python field that accepts a pandas Timestamp? I'm working on a python package where lots of method parameters and class properties are timestamps. I work with the pandas.Timestamp class to represent these timestamps, e.g.: class Event: """Events are bounded between begin an end attribu...
https://stackoverflow.com/questions/79972629/how-to-correctly-type-hint-a-python-field-that-accepts-a-pandas-timestamp
python, pandas, type-hinting, stub
1,782,996,972
se_62581883
stackoverflow
DATA_SCIENCE
Efficiently transforming rows to columns in Pandas DataFrame?
Efficiently transforming rows to columns in Pandas DataFrame? I'd like to convert the following DataFrame: idx key val 0 1 foo 2 1 1 bar 4 2 1 qux 8 3 2 foo 10 4 2 bar 12 5 2 qux 14 To: key_foo key_bar key_qux idx 1 4 2 ...
https://stackoverflow.com/questions/62581883/efficiently-transforming-rows-to-columns-in-pandas-dataframe
python, pandas, dataframe
1,593,109,187
se_71545455
stackoverflow
DATA_SCIENCE
giving a unique code by seeing the first column string and the second column
giving a unique code by seeing the first column string and the second column giving a unique code by seeing the first column string and the second columns string and whenever the first column string change it starts from 1 Example how can I do this using python?
https://stackoverflow.com/questions/71545455/giving-a-unique-code-by-seeing-the-first-column-string-and-the-second-column
python, pandas, dataframe, numpy
1,647,767,559
se_79941092
stackoverflow
DATA_SCIENCE
What are the most effective ways to learn Data Science from scratch, especially within a limited time frame?
What are the most effective ways to learn Data Science from scratch, especially within a limited time frame? I want a structured roadmap that covers: Python for Data Science NumPy, Pandas, Matplotlib, Seaborn Scikit-learn Statistics and Probability Machine Learning basics Data visualization SQL for Data Science...
https://stackoverflow.com/questions/79941092/what-are-the-most-effective-ways-to-learn-data-science-from-scratch-especially
python, pandas
1,778,763,155
se_21693133
stackoverflow
DATA_SCIENCE
R1C1 in openpyxl
R1C1 in openpyxl I'm trying to set conditional formatting in openpyxl to emulate highlighting duplicate values. With this simple code, I should be able to highlight consecutive duplicates (but not the first value in a duplicate sequence). from pandas import * data = DataFrame({'a':'a a a b b b c b c a f'.split()}) wb...
https://stackoverflow.com/questions/21693133/r1c1-in-openpyxl
python, pandas, openpyxl
1,392,092,950
se_68618478
stackoverflow
DATA_SCIENCE
Collapse overlapping columns in pandas dataframe
Collapse overlapping columns in pandas dataframe I have a dataframe that looks like this: >>> df = pd.DataFrame({'P1':['ARF5','NaN','NaN'],'P2':['NaN','M6PR','NaN'],'P3':['NaN','NaN','NDUFAF7']}) >>> df P1 P2 P3 0 ARF5 NaN NaN 1 NaN M6PR NaN 2 NaN NaN NDUFAF7 I have been trying to c...
https://stackoverflow.com/questions/68618478/collapse-overlapping-columns-in-pandas-dataframe
python, pandas, merging-data
1,627,892,627
se_79949789
stackoverflow
DATA_SCIENCE
How can I save pdb files with biopandas?
How can I save pdb files with biopandas? I have a processed pdb file and I would like to further process it and split it into 4 different files based on the labels from a clustering algorithm, which are stored in 'hlabs' variable. My file is '1asy_pocket.pdb' and I can process it with biopandas. However, after I built...
https://stackoverflow.com/questions/79949789/how-can-i-save-pdb-files-with-biopandas
python, pandas
1,780,330,544
se_79671166
stackoverflow
DATA_SCIENCE
Importing CSV after initially exporting datetime output (without using pandas)
Importing CSV after initially exporting datetime output (without using pandas) I use the following to write CSV lines in a loop while running sensor instrumentation, and I want to read them back in for post-processing without pandas. I would like to use the imported data to plot, and do basic arithmetic on the time s...
https://stackoverflow.com/questions/79671166/importing-csv-after-initially-exporting-datetime-output-without-using-pandas
python, pandas, csv, python-datetime
1,750,271,379
se_79966799
stackoverflow
DATA_SCIENCE
df.explode() has no effect when used in a for-loop
df.explode() has no effect when used in a for-loop I want to call multiple pandas-functions on multiple DataFrames with no avail. Unfortunately I do not understand why since I think it should work as pandas is referencing the DataFrames. Below is s small snippet to show the behavour, it lacks the part of multiple fram...
https://stackoverflow.com/questions/79966799/df-explode-has-no-effect-when-used-in-a-for-loop
python, pandas, dataframe
1,782,385,129
se_79968177
stackoverflow
DATA_SCIENCE
How can I read a CSV file, sum the “Betrag” column, count rows, and group totals by tenant?
How can I read a CSV file, sum the “Betrag” column, count rows, and group totals by tenant? I have a CSV file exported from Excel. It contains at least these two columns: Betrag (numeric amounts) tenant (string identifier) I want to: Read the CSV file Calculate the total sum of the Betrag column Count the numbe...
https://stackoverflow.com/questions/79968177/how-can-i-read-a-csv-file-sum-the-betrag-column-count-rows-and-group-totals
python, pandas, csv
1,782,457,334
se_79966342
stackoverflow
DATA_SCIENCE
Perfom operation between the first and second row of each group
Perfom operation between the first and second row of each group I have the following dataframe: sequence_id geometry step distance 0 0ae5nT97gFXHwxrYPsuAvS POINT (-77.03842341899872 -12.038213559379837) 0 0 1 0ae5nT97gFXHwxrYPsuAvS POINT (-77.0381498336792 -12.03833947409247) 1 32.8924 2 0ae5nT97gFXHwxrYPs...
https://stackoverflow.com/questions/79966342/perfom-operation-between-the-first-and-second-row-of-each-group
python, pandas
1,782,306,722
se_79960740
stackoverflow
DATA_SCIENCE
How to detect a specific sequence of string values within a Dataframe column
How to detect a specific sequence of string values within a Dataframe column I am performing analysis of some log files with Python/Pandas, and I am trying to develop an efficient operation to find a specific sequence of string values within a column. My current idea was to use a rolling window of 2 observations and a...
https://stackoverflow.com/questions/79960740/how-to-detect-a-specific-sequence-of-string-values-within-a-dataframe-column
python, pandas, dataframe
1,781,624,780
se_79966828
stackoverflow
DATA_SCIENCE
Is there a way to store datetime objects with different timezones in one column without losing the .dt functions that pandas provides?
Is there a way to store datetime objects with different timezones in one column without losing the .dt functions that pandas provides? I am working with the time of a location in Germany where the timezone is shifted over the year. When having two different timezones in one column pandas only recognizes it as object (...
https://stackoverflow.com/questions/79966828/is-there-a-way-to-store-datetime-objects-with-different-timezones-in-one-column
python, pandas, python-datetime, timezone-offset
1,782,389,761
se_72589797
stackoverflow
DATA_SCIENCE
ModuleNotFoundError: No module named &#39;pandas&#39; although I have already installed it
ModuleNotFoundError: No module named &#39;pandas&#39; although I have already installed it I am trying to run a python (3.9.0) code in Jupyter Notebook in VSCode. Even though I installed pandas in my virtual environment, it still shows ModuleNotFoundError: No module named 'pandas'. I tried python3 -m pip install pand...
https://stackoverflow.com/questions/72589797/modulenotfounderror-no-module-named-pandas-although-i-have-already-installed
python, pandas, visual-studio-code, jupyter-notebook
1,655,013,074
se_43834242
stackoverflow
DATA_SCIENCE
SKLearn MinMaxScaler - scale specific columns only
SKLearn MinMaxScaler - scale specific columns only I'd like to scale some (but not all) of the columns in a Pandas dataFrame using a MinMaxScaler. How can I do it?
https://stackoverflow.com/questions/43834242/sklearn-minmaxscaler-scale-specific-columns-only
pandas, scikit-learn
1,494,176,514
se_38420847
stackoverflow
DATA_SCIENCE
Apply StandardScaler to parts of a data set
Apply StandardScaler to parts of a data set I want to use sklearn's StandardScaler. Is it possible to apply it to some feature columns but not others? For instance, say my data is: data = pd.DataFrame({'Name' : [3, 4,6], 'Age' : [18, 92,98], 'Weight' : [68, 59,49]}) Age Name Weight 0 18 3 68 1 92 ...
https://stackoverflow.com/questions/38420847/apply-standardscaler-to-parts-of-a-data-set
python, pandas, scikit-learn
1,468,756,027
se_79966343
stackoverflow
DATA_SCIENCE
How to use StandardScaler on only specific columns in a pandas DataFrame?
How to use StandardScaler on only specific columns in a pandas DataFrame? I have a DataFrame with three columns: 'power', 'time', and 'status'. The 'status' column contains 0 or 1 (target variable). I don't want to scale the 'status' column. How can I apply StandardScaler to only the 'power' and 'time' columns while k...
https://stackoverflow.com/questions/79966343/how-to-use-standardscaler-on-only-specific-columns-in-a-pandas-dataframe
python, pandas, scikit-learn
1,782,306,997
se_23353732
stackoverflow
DATA_SCIENCE
Python Pandas write to sql with NaN values
Python Pandas write to sql with NaN values I'm trying to read a few hundred tables from ascii and then write them to mySQL. It seems easy to do with Pandas but I hit an error that doesn't make sense to me: I have a data frame of 8 columns. Here is the column list/index: metricDF.columns Index([u'FID', u'TYPE', u'...
https://stackoverflow.com/questions/23353732/python-pandas-write-to-sql-with-nan-values
python, mysql, sql, pandas
1,398,733,139
se_79956503
stackoverflow
DATA_SCIENCE
How to count how many times string X appears in a row (and how to turn answer into a table)?
How to count how many times string X appears in a row (and how to turn answer into a table)? I need to make a bar chart to show the abundance of specific genes in samples. In my large Excel file, each row is a different sample and each sample has a different number of genes (meaning counting by column isn't practical)...
https://stackoverflow.com/questions/79956503/how-to-count-how-many-times-string-x-appears-in-a-row-and-how-to-turn-answer-in
python, pandas
1,781,180,292
se_58523316
stackoverflow
DATA_SCIENCE
split rows in pandas dataframe
split rows in pandas dataframe I stuck with the problem how to divide a pandas dataframe by row, I have a similar dataframe with a column where values are separated by \r\n and they are in one cell, Color Shape Price 0 Green Rectangle\r\nTriangle\r\nOctangle 10 1 Blue ...
https://stackoverflow.com/questions/58523316/split-rows-in-pandas-dataframe
python, pandas
1,571,835,158
se_17116814
stackoverflow
DATA_SCIENCE
How to split text in a column into multiple rows
How to split text in a column into multiple rows The second to last column has a string of text that I want to split by a specific delimiter. Is there a simple way to do this using pandas or python? CustNum CustomerName ItemQty Item Seatblocks ItemExt 32363 McCartney, Paul 3 F04 ...
https://stackoverflow.com/questions/17116814/how-to-split-text-in-a-column-into-multiple-rows
python, pandas, dataframe
1,371,241,966
se_45574191
stackoverflow
DATA_SCIENCE
Using Python Faker generate different data for 5000 rows
Using Python Faker generate different data for 5000 rows I would like to use the Python Faker library to generate 500 lines of data, however I get repeated data using the code I came up with below. Can you please point out where I'm going wrong. I believe it has something to do with the for loop. Thanks in advance: f...
https://stackoverflow.com/questions/45574191/using-python-faker-generate-different-data-for-5000-rows
python-3.x, pandas, dataframe, random, faker
1,502,211,936
se_79965209
stackoverflow
DATA_SCIENCE
Find value in data from CSV read with Pandas
Find value in data from CSV read with Pandas Using Pandas I read a CSV file: import pandas as pd fcsv = pd.read_csv("my_file.csv", sep=";", usecols=[4,6]) print(fcsv) ID Use_Fuel 0 15454509, 00664154 No 1 00928674, 10974172 No 2 15453278, 07320582 No...
https://stackoverflow.com/questions/79965209/find-value-in-data-from-csv-read-with-pandas
python, pandas
1,782,123,920
se_48187884
stackoverflow
DATA_SCIENCE
EmptyDataError: No columns to parse from file
EmptyDataError: No columns to parse from file Currently I am getting the below Error and I am tried out the below posts: Solution 1 Solution 2 But I am not able to get the error resolved. My python code is as below: import pandas as pd testdata = pd.read_csv(file_name, header=None, delim_whitespace=True) I trie...
https://stackoverflow.com/questions/48187884/emptydataerror-no-columns-to-parse-from-file
python, pandas, csv
1,515,588,573
se_61101680
stackoverflow
DATA_SCIENCE
install pandas on rhel using yum
install pandas on rhel using yum If I want to install pandas on RHEL server using the following command from the official pandas documentation pandas installation using the following command: yum install python3-pandas I get the following error: No package python3-pandas available Nothing to do Below are the spe...
https://stackoverflow.com/questions/61101680/install-pandas-on-rhel-using-yum
python, pandas, installation, yum, rhel
1,586,351,880