289,250 questions
-1
votes
1
answer
51
views
putting looped API Call results into a dataframe in Python
i need some help. have got a part of a python script which accesses a url field in a sql database, and then calls an api based using the url in the field. Now i cannot get the data into a dataframe to ...
0
votes
1
answer
56
views
pd.api.types.is_string_dtype() is misleading
df = pd.DataFrame({
'col_str': ["a", "b", "c"],
'col_lst_str': [["a", "b", "c"], ["d", "e", "f"], [&...
3
votes
3
answers
82
views
Why is pandas not formatting dates with date_format?
Why is pandas not formatting dates with date_format argument of to_csv?
pandas.DataFrame([datetime.datetime.now().date()]).to_csv(date_format="%Y %b")
',0\n0,2025-07-31\n'
1
vote
1
answer
95
views
How to replace existing data in a particular sheet of an existing excel file using pyspark dataframe?
I am using Azure Databricks and Azure Data Storage Explorer for my operations. I have an excel file of under 30 MB containing multiple sheets. I want to replace the data in one sheet every month when ...
-3
votes
1
answer
73
views
How to convert sql formula to python or pandas code [closed]
I have a syntax like below and would like to convert this to python executable statement.
The below is stored as it is in the database and used in a procedure for calculating the required value.
Now I ...
3
votes
5
answers
151
views
How to merge two CSV files based on matching values in different columns and keep unmatched rows with placeholders?
I'm working on a data cleaning task and could use some help. I have two CSV files with thousands of rows each:
File A contains product shipment records.
File B contains product descriptions and ...
-2
votes
0
answers
67
views
Column named read as tuple instead of string in pandas [closed]
I have a column ContentVideo that exists in pandas df.
Trying to do this trasnformation
data.loc[data.ContentVideo == 0, "play_rate"] = 0
however, when I am getting this error
~~~~~~~~^^^...
4
votes
4
answers
134
views
How to fill values in a Dataframe depending on values around it
I have a dataframe that looks something like this:
1 2 3 'String'
'' 4 X ''
'' 5 X ''
'' 6 7 'String'
'' 1 Y ''
And I want to change the Xs and Ys (put here just to visualize) to the ...
1
vote
1
answer
110
views
In pandas, how to write the word "nan" as string with to_excel?
I have the reverse problem as described in Prevent pandas from interpreting 'NA' as NaN in a string.
I work with older English text data and want to write the word "nan" (i.e. Modern ...
6
votes
5
answers
261
views
How to generate this simple dataframe from these numbers?
I have N numbers, call it 3 for now: A1, A2, A3. I'd like to generate the following dataframe in Pandas:
Category
1
2
3
4
5
6
7
1
A1
A1+A2
A1+A2+A3
A2+A3
A3
0
0
2
0
A2
A2+A3
A2+A3+A1
A3+A1
A1
0
3
0
0
...
-2
votes
2
answers
162
views
Why grouping a pandas series using the same series makes no sense?
In the code example below I am grouping a pandas series using the same series but with a modified index.
The groups in the end make no sense. There is no warning or error.
Could you please help me ...
2
votes
2
answers
66
views
Pandas dt accessor or groupby function returning decimal numbers instead of integers in index labels where some series values NA
We're trying to group up date counts by month and index values are returning as decimals instead of integers when series contain any number of NaTs / na values.
Simplified reproducible example:
import ...
0
votes
0
answers
44
views
How to call R's stlm() from Python using rpy2, getting "missing value where TRUE/FALSE needed" error
I’m using rpy2 in Python to call R's forecast::stlm() function from within a custom wrapper function defined in R. My goal is to fit a seasonal time series model (STL + ARIMA) on a univariate time ...
-3
votes
0
answers
72
views
Performance Issues Replacing Oracle Packages with Python3 Inline Queries using cx_Oracle in AKS [closed]
We are currently migrating our Oracle PL/SQL packages to Python 3, using inline SQL queries and executing them via cx_Oracle and oracledb Python packages. The setup is deployed in Azure Kubernetes ...
-2
votes
1
answer
95
views
Merge date with error - If using all scalar values, you must pass an index [closed]
Data like this:
date,stockIndex
2024-01-02,17853.76
2024-01-03,17559.31
2024-01-04,17549.65
2024-01-05,17519.14
2024-01-08,17572.66
2024-01-09,17535.4
2024-01-10,17465.63
Python Code
import pandas as ...