New answers tagged pandas
2
votes
Accepted
Generate date_range for string intervals like 09:00-10:00/11:00-14:00/15:00-18:00 and calculate the working minutes
Consider revamping your current setup to work mostly in Pandas methods that operates on whole DataFrames and Series objects as opposed to mostly built-in Python methods on scalar values that loop and ...
2
votes
Generate date_range for string intervals like 09:00-10:00/11:00-14:00/15:00-18:00 and calculate the working minutes
Things that are good to stay in Spanish: your starting input file, your final output file. Everything else - your variable names, function names, comments, parameter names, and the column names of ...
2
votes
Python script for Web scraping
When using Requests to fetch JSON content, it's usually more convenient to use the resonse.json() method instead of manually passing ...
0
votes
Optimise pandas code using def(x) and multiprocessing
Consider tightening up this code with the below tips. There may even be room to remove methods that do not seem required with sample of data. Maybe this is legacy code that needs updating.
Source: ...
3
votes
Accepted
Create new columns based on existing columns
Don't loop. Pandas is designed to be vectorised, which means that 99% of the time when you imagine an operation to require a loop, that loop should be baked into some Numpy or Pandas call rather than ...
5
votes
Create new columns based on existing columns
The content of the loop is of the form
if condition:
continue
else:
action()
It would probably be easier to read as
...
1
vote
Regex and pandas to read forecast sky condition string
You've landed in trouble with your indices again. I think the shape of your dataframe significantly mischaracterises what your data are actually saying:
Per station,
per station observation time,
per ...
2
votes
Accepted
Regex and pandas to read forecast sky condition string
At the start of get_sky_condition(), I don't see why you do a .str.strip() when defining ...
2
votes
Accepted
Regex pattern matching to generate pandas multi index
indexs should be spelled indices.
Your implementation is non-vectorised and should make use of the Pandas ...
2
votes
Read a file format with mixed CSV and non-CSV content
While Reinderien posted an excellent solution to your problem. Let me take a closer look and give you some feedback on your code.
Let us just focus on the 3 biggest things which stands out to me and ...
2
votes
Read a file format with mixed CSV and non-CSV content
You're working too hard. You concatenate all of the CSV rows anyway, so LINES= has no value. Just read the CSV, and choose an easy way to identify invalid rows - ...
Top 50 recent answers are included
Related Tags
pandas × 570python × 558
python-3.x × 155
performance × 139
numpy × 80
csv × 43
beginner × 30
datetime × 22
matplotlib × 21
statistics × 20
python-2.x × 18
machine-learning × 18
excel × 17
time-limit-exceeded × 12
regex × 11
hash-map × 11
web-scraping × 11
data-visualization × 11
object-oriented × 10
strings × 9
parsing × 9
finance × 9
beautifulsoup × 9
geospatial × 9
data-mining × 9