148,691 questions
1
vote
0
answers
41
views
Why does the "$" operator not run when using the unique() function while trying to extract a specific variable from a dataset
I am trying to run a for loop that will extract variables from two different datasets into one data frame. One dataset contains information on estuaries of the West Coast of North America, the other ...
0
votes
1
answer
53
views
Put all row from a data in a list
I am having a problem to put an entire row from data in a list
import pandas as pd
import numpy as np
import csv
df= pd.read_csv ("data.csv")
my_list = [] # list
for n in range(1, ...
2
votes
3
answers
102
views
How to modify mulitple columns applying if else to multiple pandas dataframe columns
I have a dataFrame with columns Age, Salary and others, if I used:
df['Age'] = df['Age'].apply(lambda x : x+100 if x>30 else 0)
Then I can modify the Age column with the if else condition. Also, if ...
0
votes
1
answer
99
views
How to create 2 new columns in R (date difference + convert Seasons to minutes)? [duplicate]
I am new to R and trying to create two new variables from my dataset.
My data frame is called netflix and it contains these relevant columns:
date_added and duration
Example values:
date_added: "...
1
vote
0
answers
47
views
How to show the streaming parts of a polars query using explain()?
I am trying to explain() a Polars query to see which operations can be executed using the streaming engine. Currently, I am only able to do this using show_graph().
From sources on the web, I see that ...
Advice
1
vote
2
replies
81
views
Show the timezone when printing a data frame with a `POSIXct` column
Is there a simple way (i.e., not involoving writing a print() method) to show the timezone when printing a data frame with a POSIXct column ?
as.data.frame(Sys.time())
# Sys.time()
# 1 2025-...
-1
votes
1
answer
92
views
Why does groupby().apply() produce inconsistent results on identical groups when the DataFrame has overlapping indices? [closed]
I noticed that groupby().apply() produces different results for two groups that look identical, except that the overall DataFrame has duplicate index values.
Here is a minimal reproducible example:
...
1
vote
1
answer
66
views
Polars parse multiple datetime format [duplicate]
I have string column in polars dataframe with multiple datetime formats and I am using following code to convert datatype of column from string into datetime.
import polars as pl
df = pl.from_dict({'...
0
votes
0
answers
72
views
polars.LazyFrame.sink_csv does not give CRLF line termination [duplicate]
I have a Python file
import polars as pl
import requests
from pathlib import Path
url = "https://raw.githubusercontent.com/leanhdung1994/files/main/processedStep1_enwiktionary_namespace_0_43....
0
votes
1
answer
153
views
Construct a simple loop to create new data frames in R [closed]
I have a number of data.frames, with names apple, banana, and coffee. I want to create, and then export, new dataframes in a for-loop corresponding to each one, call them apple_new, banana_new, and ...
2
votes
4
answers
154
views
How to split dataframe into multiple sub-dataframes based on column value
I got a dataframe df1 which looks like this:
Column1
Column2
13
1
12
1
15
0
16
0
15
1
14
1
12
1
11
0
21
1
45
1
44
0
The 1s indicate that a measurement started, I don't know how many 1s will be in one ...
1
vote
3
answers
168
views
Polars: how to write a column of strings into a txt file without escaping?
I have a .ndjson files with millions of rows. Each row has a field html which contains html strings. I would like to write all such html into a .txt file. One html is into one line of the .txt file. I ...
5
votes
2
answers
109
views
How to resample timeseries with origin aligned to start of year
Consider the following pandas Series with a DatatimeIndex of daily values (using day-of-year as an example):
import pandas as pd
dti = pd.date_range("2017-11-02", "2019-05-21", ...
2
votes
1
answer
133
views
Why does a nearest join_asof() return exact matches despite allow_exact_matches=False?
I am looking for the nearest non exact match on the dates column:
import polars as pl
df = pl.from_repr("""
┌─────┬────────────┐
│ uid ┆ dates │
│ --- ┆ --- │
│ i64 ┆ date ...
Tooling
0
votes
2
replies
67
views
How to export or import TOON in pandas?
I would like to know how to export or import TOON (Token object oriented notation) in pandas.