rename

After rename column get keyerror

偶尔善良 提交于 2019-12-17 07:49:30
问题 I have df : df = pd.DataFrame({'a':[7,8,9], 'b':[1,3,5], 'c':[5,3,6]}) print (df) a b c 0 7 1 5 1 8 3 3 2 9 5 6 Then rename first value by this: df.columns.values[0] = 'f' All seems very nice: print (df) f b c 0 7 1 5 1 8 3 3 2 9 5 6 print (df.columns) Index(['f', 'b', 'c'], dtype='object') print (df.columns.values) ['f' 'b' 'c'] If select b it works nice: print (df['b']) 0 1 1 3 2 5 Name: b, dtype: int64 But if select a it return column f : print (df['a']) 0 7 1 8 2 9 Name: f, dtype: int64

How do I move file a to a different partition or device in Node.js?

谁说胖子不能爱 提交于 2019-12-17 07:22:45
问题 I'm trying to move a file from one partition to another in a Node.js script. When I used fs.renameSync I received Error: EXDEV, Cross-device link . I'd copy it over and delete the original, but I don't see a command to copy files either. How can this be done? 回答1: You need to copy and unlink when moving files across different partitions. Try this, var fs = require('fs'); //var util = require('util'); var is = fs.createReadStream('source_file'); var os = fs.createWriteStream('destination_file'

How to rename a file on sdcard with Android application?

寵の児 提交于 2019-12-17 06:43:39
问题 In my Android application, I want to rename the file name at runtime. How can I do it? This is my code: String[] command = {" mv", "sun moon.jpg"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo(File f) method but it does not work. 回答1: I would recommend using File.renameTo() rather than running the mv command, since I'm fairly sure the latter isn't supported..

How to rename a file on sdcard with Android application?

家住魔仙堡 提交于 2019-12-17 06:43:18
问题 In my Android application, I want to rename the file name at runtime. How can I do it? This is my code: String[] command = {" mv", "sun moon.jpg"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo(File f) method but it does not work. 回答1: I would recommend using File.renameTo() rather than running the mv command, since I'm fairly sure the latter isn't supported..

Renaming multiple files in a directory using Python

半腔热情 提交于 2019-12-17 06:38:30
问题 I'm trying to rename multiple files in a directory using this Python script: import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1 When I run this script, I get the following error: Traceback (most recent call last): File "rename.py", line 7, in <module> os.rename(file, str(i)+'.jpg') OSError: [Errno 2] No such file or directory Why is that? How can I solve this issue? Thanks. 回答1: You are not giving the

Get the Perl rename utility instead of the built-in rename

假如想象 提交于 2019-12-17 05:02:20
问题 Many sites (including various SO articles) talk about using "rename" using Perl expressions to rename files. This would be perfect, but apparently this is not the rename utility I have, and none of these articles seem to comprehend that there are multiple versions of "rename" and I can't seem to find where to get version that accepts Perl expressions. How can I get my hands on the more powerful rename utility mentioned here, here, and here? I'm running Fedora 20. My current rename command is

How to rename with prefix/suffix?

房东的猫 提交于 2019-12-17 04:43:45
问题 How do I do mv original.filename new.original.filename without retyping the original filename? I would imagine being able to do something like mv -p=new. original.filename or perhaps mv original.filename new.~ or whatever - but I can't see anything like this after looking at man mv / info mv pages. Of course, I could write a shell script to do this, but isn't there an existing command/flag for it? 回答1: In Bash and zsh you can do this with Brace Expansion. This simply expands a list of items

How do I rename all folders and files to lowercase on Linux?

寵の児 提交于 2019-12-17 03:21:57
问题 I have to rename a complete folder tree recursively so that no uppercase letter appears anywhere (it's C++ source code, but that shouldn't matter). Bonus points for ignoring CVS and Subversion version control files/folders. The preferred way would be a shell script, since a shell should be available on any Linux box. There were some valid arguments about details of the file renaming. I think files with the same lowercase names should be overwritten; it's the user's problem. When checked out

Rename file while keeping the extension in Linux?

孤者浪人 提交于 2019-12-14 04:09:26
问题 I have a directory that contains multiple files with different extensions (pdf, doc, txt...etc). I'm trying to rename all files according to the directory name while keeping the file extension the same. The code below works fine if all files are PDF otherwise it will change txt file extension to pdf too. How can I rename files while preserving the file extension mv "$file" "${dir}/${dir}-${count}.pdf" 回答1: you can do this through bash. can you please provide more details. how your deciding

Aptana3 rename variable in a file

核能气质少年 提交于 2019-12-14 02:22:20
问题 It is very useful for with CTRL+1 and then CTRL+2 in Eclipse for rename a variable in certain scope. But in Aptana 3, in javascript editor, I can't find this function, can anyone help? 回答1: Aptana does not have this feature. Check this IDE comparative: 来源: https://stackoverflow.com/questions/22389718/aptana3-rename-variable-in-a-file